Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
curvedflats
Commits
8a24918b
Commit
8a24918b
authored
Aug 22, 2019
by
16이진형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grab 호출 구조 변경
parent
3c98bc0f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
31 deletions
+136
-31
IGrabable.cs
Assets/Scripts/Interface/IGrabable.cs
+15
-0
IGrabable.cs.meta
Assets/Scripts/Interface/IGrabable.cs.meta
+11
-0
IGraber.cs
Assets/Scripts/Interface/IGraber.cs
+17
-0
IGraber.cs.meta
Assets/Scripts/Interface/IGraber.cs.meta
+11
-0
IInteractable.cs
Assets/Scripts/Interface/IInteractable.cs
+2
-2
IInteractor.cs
Assets/Scripts/Interface/IInteractor.cs
+7
-2
GrabableObject.cs
Assets/Scripts/ObjectMovement/GrabableObject.cs
+25
-15
PlayerMovement.cs
Assets/Scripts/ObjectMovement/PlayerMovement.cs
+45
-3
InteractiveObject.cs
Assets/Scripts/ObjectMovement/abstract/InteractiveObject.cs
+3
-9
No files found.
Assets/Scripts/Interface/IGrabable.cs
0 → 100644
View file @
8a24918b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Assets.Scripts.Interface
{
public
interface
IGrabable
{
void
OnGrabbed
(
IGraber
graber
);
bool
IsGrabbed
{
get
;
}
}
}
Assets/Scripts/Interface/IGrabable.cs.meta
0 → 100644
View file @
8a24918b
fileFormatVersion: 2
guid: 845b5f3d9f326274d960d67947d8f987
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Interface/IGraber.cs
0 → 100644
View file @
8a24918b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
UnityEngine
;
namespace
Assets.Scripts.Interface
{
public
interface
IGraber
{
void
OnGrab
(
IGrabable
grabed
);
Vector3
GraberV
{
get
;
}
bool
IsGrab
{
get
;
}
}
}
Assets/Scripts/Interface/IGraber.cs.meta
0 → 100644
View file @
8a24918b
fileFormatVersion: 2
guid: 981976f1f25218f498f2aa24ae06643b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Interface/IInteractable.cs
View file @
8a24918b
...
...
@@ -6,9 +6,9 @@ using System.Threading.Tasks;
namespace
Assets.Scripts.Interface
{
interface
IInteractable
public
interface
IInteractable
{
void
OnInteract
();
void
OnInteract
(
IInteractor
interactor
);
string
InteractType
{
get
;
}
}
...
...
Assets/Scripts/Interface/IInteractor.cs
View file @
8a24918b
...
...
@@ -6,8 +6,13 @@ using System.Threading.Tasks;
namespace
Assets.Scripts.Interface
{
interface
IInteractor
public
interface
IInteractor
{
void
OnInteract
();
void
OnInteract
(
IInteractable
interactable
);
IGraber
IsGraber
{
get
;
}
}
}
Assets/Scripts/ObjectMovement/GrabableObject.cs
View file @
8a24918b
...
...
@@ -3,13 +3,15 @@ using System.Collections.Generic;
using
UnityEngine
;
using
Assets.Scripts.Interface
;
public
class
GrabableObject
:
InteractiveObject
public
class
GrabableObject
:
InteractiveObject
,
IGrabable
{
protected
bool
toggle
=
false
;
protected
bool
grabbed
=
false
;
protected
IGraber
graber
;
public
override
string
InteractType
{
get
...
...
@@ -18,30 +20,38 @@ public class GrabableObject : InteractiveObject
}
}
public
override
void
OnInteract
()
public
bool
IsGrabbed
{
return
;
get
{
return
grabbed
;
}
}
p
rotected
override
void
FixedUpdate
(
)
p
ublic
void
OnGrabbed
(
IGraber
graber
)
{
if
((
levelManager
.
player
.
transform
.
position
-
transform
.
position
).
magnitude
<
1f
)
{
toggle
=
true
;
}
else
{
toggle
=
false
;
}
grabbed
=
!
grabbed
;
}
if
(
toggle
&&
Input
.
GetKeyDown
(
"g"
))
public
override
void
OnInteract
(
IInteractor
interactor
)
{
if
(
interactor
.
IsGraber
!=
null
)
{
grabbed
=
!
grabbed
;
graber
=
interactor
.
IsGraber
;
if
(!
graber
.
IsGrab
)
{
graber
.
OnGrab
(
this
);
OnGrabbed
(
graber
);
}
}
}
protected
override
void
FixedUpdate
()
{
if
(
grabbed
)
{
v
=
levelManager
.
player
.
v
;
v
=
graber
.
GraberV
;
Debug
.
Log
(
"being grabbed"
);
}
...
...
Assets/Scripts/ObjectMovement/PlayerMovement.cs
View file @
8a24918b
...
...
@@ -5,9 +5,10 @@ using MathNet.Numerics.LinearAlgebra;
using
MathNet.Numerics.LinearAlgebra.Double
;
using
Assets.Scripts.Interface
;
public
class
PlayerMovement
:
FlatlandMovement
,
IInteractor
public
class
PlayerMovement
:
FlatlandMovement
,
IInteractor
,
IGraber
{
bool
isinertial
=
true
;
bool
isGrab
=
false
;
public
GameObject
background
;
...
...
@@ -49,6 +50,11 @@ public class PlayerMovement : FlatlandMovement,IInteractor
uiManager
.
InteractText
=
""
;
}
if
(
Input
.
GetKeyDown
(
"g"
))
{
OnInteract
(
TryFindClosestInterativeObject
());
}
}
...
...
@@ -175,12 +181,26 @@ public class PlayerMovement : FlatlandMovement,IInteractor
return
isinertial
;
}
}
//interactor 구현
public
void
OnInteract
()
public
IGraber
IsGraber
{
return
;
get
{
return
this
;
}
}
public
void
OnInteract
(
IInteractable
interactable
)
{
if
(
interactable
==
null
)
{
return
;
}
interactable
.
OnInteract
(
this
);
}
//충돌
public
override
void
OnCollisionEnterchild
(
Collision
collision
)
{
base
.
OnCollisionEnterchild
(
collision
);
...
...
@@ -232,4 +252,26 @@ public class PlayerMovement : FlatlandMovement,IInteractor
return
result
;
}
//grab 구현
public
void
OnGrab
(
IGrabable
grabed
)
{
isGrab
=
true
;
}
public
Vector3
GraberV
{
get
{
return
v
;
}
}
public
bool
IsGrab
{
get
{
return
isGrab
;
}
}
}
Assets/Scripts/ObjectMovement/abstract/InteractiveObject.cs
View file @
8a24918b
...
...
@@ -5,16 +5,10 @@ using Assets.Scripts.Interface;
public
abstract
class
InteractiveObject
:
Planemovement
,
IInteractable
{
public
virtual
string
InteractType
public
abstract
string
InteractType
{
get
{
return
"grab"
;
}
get
;
}
public
virtual
void
OnInteract
()
{
return
;
}
public
abstract
void
OnInteract
(
IInteractor
interactor
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment