Commit e262495f authored by 16이진형's avatar 16이진형

무브먼트 상속구조&코드 정리

parent 8865b3dc
...@@ -1110,11 +1110,11 @@ MonoBehaviour: ...@@ -1110,11 +1110,11 @@ MonoBehaviour:
m_GameObject: {fileID: 535323107} m_GameObject: {fileID: 535323107}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0bf826b8a4774ba4b9c6a1cff6925667, type: 3} m_Script: {fileID: 11500000, guid: 11c0c0a758005e0408c9a767ec478e97, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
objectType: 1 objectType: 2
collisionPreset: 1 collisionPreset: 2
beta: 0 beta: 0
alpha: {x: 0, y: 0, z: 0} alpha: {x: 0, y: 0, z: 0}
v: {x: 0, y: 0, z: 0} v: {x: 0, y: 0, z: 0}
...@@ -1122,10 +1122,10 @@ MonoBehaviour: ...@@ -1122,10 +1122,10 @@ MonoBehaviour:
levelManager: {fileID: 279236944} levelManager: {fileID: 279236944}
gamma: 1 gamma: 1
time: 0 time: 0
theobject: {fileID: 439858915} theobject: {fileID: 535323107}
mass: 10 mass: 10
starttime: 10 starttime: 60
otherclock: {fileID: 0} otherclock: {fileID: 1094934749}
--- !u!4 &535323109 --- !u!4 &535323109
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2666,7 +2666,7 @@ MonoBehaviour: ...@@ -2666,7 +2666,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1094934748} m_GameObject: {fileID: 1094934748}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 36bd4b20d3bc814459c577f508eda20c, type: 3} m_Script: {fileID: 11500000, guid: 11c0c0a758005e0408c9a767ec478e97, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
objectType: 2 objectType: 2
...@@ -2678,7 +2678,7 @@ MonoBehaviour: ...@@ -2678,7 +2678,7 @@ MonoBehaviour:
levelManager: {fileID: 279236944} levelManager: {fileID: 279236944}
gamma: 1 gamma: 1
time: 0 time: 0
theobject: {fileID: 839664886} theobject: {fileID: 1094934748}
mass: 10 mass: 10
starttime: 0 starttime: 0
otherclock: {fileID: 535323108} otherclock: {fileID: 535323108}
......
fileFormatVersion: 2
guid: f16f22524f097944c8753aa297ecdb50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
public class Clock : GrabableObject
{
public double starttime = 0.0f;
public Clock otherclock;
private new void Start()
{
base.Start();
time = starttime;
}
public override void OnCollisionStaychild(Collision collision)
{
base.OnCollisionStaychild(collision);
//Debug.Log("hit!");
//if(collision.transform.parent.name != "AnObject(Clone)")
// Debug.Log(collision.gameObject.name + " wow!");
if (collision.transform.parent != null)
{
var x = collision.transform.parent.gameObject.GetComponent(typeof(Clock)) as Clock;
if (x != null && x.Equals(otherclock))
{
Debug.Log("hit!");
if (Mathf.Abs((float)(otherclock.GetTime() - time)) <= 1.0f)
{
levelManager.winstate = true;
}
else
{
Debug.Log(Mathf.Abs((float)(otherclock.GetTime() - time)));
}
}
}
}
public double GetTime()
{
return time;
}
}
fileFormatVersion: 2
guid: 11c0c0a758005e0408c9a767ec478e97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -5,6 +5,11 @@ using Assets.Scripts.Interface; ...@@ -5,6 +5,11 @@ using Assets.Scripts.Interface;
public class GrabableObject : InteractiveObject public class GrabableObject : InteractiveObject
{ {
protected bool toggle = false;
protected bool grabbed = false;
public override string InteractType public override string InteractType
{ {
get get
...@@ -17,4 +22,29 @@ public class GrabableObject : InteractiveObject ...@@ -17,4 +22,29 @@ public class GrabableObject : InteractiveObject
{ {
return; return;
} }
protected override void FixedUpdate()
{
if ((levelManager.player.transform.position - transform.position).magnitude < 1f)
{
toggle = true;
}
else
{
toggle = false;
}
if (toggle && Input.GetKeyDown("g"))
{
grabbed = !grabbed;
}
if (grabbed)
{
v = levelManager.player.v;
Debug.Log("being grabbed");
}
base.FixedUpdate();
}
} }
...@@ -18,7 +18,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor ...@@ -18,7 +18,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor
private Vector3 backgroundStartScale; private Vector3 backgroundStartScale;
// Start is called before the first frame update // Start is called before the first frame update
void Start() protected override void Start()
{ {
base.Start(); base.Start();
v = new Vector3(0.0f, 0.0f, 0.0f); v = new Vector3(0.0f, 0.0f, 0.0f);
...@@ -34,7 +34,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor ...@@ -34,7 +34,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor
} }
void Update() protected override void Update()
{ {
base.Update(); base.Update();
...@@ -53,7 +53,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor ...@@ -53,7 +53,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor
} }
// Update is called once per frame // Update is called once per frame
void FixedUpdate() protected override void FixedUpdate()
{ {
base.FixedUpdate(); base.FixedUpdate();
...@@ -168,9 +168,12 @@ public class PlayerMovement : FlatlandMovement,IInteractor ...@@ -168,9 +168,12 @@ public class PlayerMovement : FlatlandMovement,IInteractor
time += Time.fixedDeltaTime; time += Time.fixedDeltaTime;
} }
public bool isInertial() public bool IsInertial
{ {
return isinertial; get
{
return isinertial;
}
} }
public void OnInteract() public void OnInteract()
...@@ -187,7 +190,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor ...@@ -187,7 +190,7 @@ public class PlayerMovement : FlatlandMovement,IInteractor
if (x) if (x)
{ {
//상호작용가능한 물건일때 //상호작용가능한 물건일때
Debug.Log(x.InteractType); //Debug.Log(x.InteractType);
interactiveObjects.Add(x); interactiveObjects.Add(x);
//uiManager.InteractText = x.InteractType; //uiManager.InteractText = x.InteractType;
} }
...@@ -199,12 +202,12 @@ public class PlayerMovement : FlatlandMovement,IInteractor ...@@ -199,12 +202,12 @@ public class PlayerMovement : FlatlandMovement,IInteractor
base.OnCollisionExitchild(collision); base.OnCollisionExitchild(collision);
if (collision.transform.parent != null) if (collision.transform.parent != null)
{ {
Debug.Log("Collision"); //Debug.Log("Collision");
InteractiveObject x = collision.transform.parent.gameObject.GetComponent<InteractiveObject>(); InteractiveObject x = collision.transform.parent.gameObject.GetComponent<InteractiveObject>();
if (x) if (x)
{ {
//상호작용가능한 물건일때 //상호작용가능한 물건일때
Debug.Log(x.InteractType); //Debug.Log(x.InteractType);
interactiveObjects.Remove(x); interactiveObjects.Remove(x);
//uiManager.InteractText = x.InteractType; //uiManager.InteractText = x.InteractType;
} }
......
fileFormatVersion: 2
guid: 12f466c4445ac32479d78a72afc69462
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -16,11 +16,6 @@ public class FlatlandMovement : MonoBehaviour ...@@ -16,11 +16,6 @@ public class FlatlandMovement : MonoBehaviour
protected CollisionType[] howToCollison; protected CollisionType[] howToCollison;
protected bool toggle = false;
protected bool grabbed = false;
protected int cnt = 0; protected int cnt = 0;
[SerializeField] [SerializeField]
...@@ -64,7 +59,7 @@ public class FlatlandMovement : MonoBehaviour ...@@ -64,7 +59,7 @@ public class FlatlandMovement : MonoBehaviour
public ObjectType ObjectType { get { return objectType; } } public ObjectType ObjectType { get { return objectType; } }
protected void Start() protected virtual void Start()
{ {
Physics.IgnoreLayerCollision(0, 1); Physics.IgnoreLayerCollision(0, 1);
startScale = theobject.transform.localScale; startScale = theobject.transform.localScale;
...@@ -90,7 +85,7 @@ public class FlatlandMovement : MonoBehaviour ...@@ -90,7 +85,7 @@ public class FlatlandMovement : MonoBehaviour
} }
} }
protected void FixedUpdate() protected virtual void FixedUpdate()
{ {
if (isAutoMove) if (isAutoMove)
{ {
...@@ -99,8 +94,8 @@ public class FlatlandMovement : MonoBehaviour ...@@ -99,8 +94,8 @@ public class FlatlandMovement : MonoBehaviour
if (SpaceLength(nowDest, transform.position) < 0.1f || SpaceInnerPorduct(nowDest - tmp, v) < 0) if (SpaceLength(nowDest, transform.position) < 0.1f || SpaceInnerPorduct(nowDest - tmp, v) < 0)
{ {
//목적지 근접 or 넘어가면 //목적지 근접 or 넘어가면
Debug.Log("dest" + nowDest); //Debug.Log("dest" + nowDest);
Debug.Log("position" + transform.position); //Debug.Log("position" + transform.position);
//넘어간만큼 보정. //넘어간만큼 보정.
//TODO : 좀더 엄밀하게 수정 필요. //TODO : 좀더 엄밀하게 수정 필요.
...@@ -128,7 +123,7 @@ public class FlatlandMovement : MonoBehaviour ...@@ -128,7 +123,7 @@ public class FlatlandMovement : MonoBehaviour
} }
} }
protected void Update() protected virtual void Update()
{ {
} }
...@@ -287,11 +282,11 @@ public class FlatlandMovement : MonoBehaviour ...@@ -287,11 +282,11 @@ public class FlatlandMovement : MonoBehaviour
private void NextMove() private void NextMove()
{ {
Debug.Log("a"+dests.Count); //Debug.Log("a"+dests.Count);
var dest = dests.Dequeue(); var dest = dests.Dequeue();
var vel = pathVelocitys.Dequeue(); var vel = pathVelocitys.Dequeue();
MoveToAbPosition(dest, vel); MoveToAbPosition(dest, vel);
Debug.Log("b"+dests.Count); //Debug.Log("b"+dests.Count);
if (isPatrol) if (isPatrol)
{ {
dests.Enqueue(dest); dests.Enqueue(dest);
...@@ -356,7 +351,7 @@ public class FlatlandMovement : MonoBehaviour ...@@ -356,7 +351,7 @@ public class FlatlandMovement : MonoBehaviour
collisionforce = tmp; collisionforce = tmp;
alpha += collisionforce; alpha += collisionforce;
Debug.Log(collisions.Count); //Debug.Log(collisions.Count);
} }
/// <summary> /// <summary>
/// 나갔을때 호출 /// 나갔을때 호출
......
...@@ -4,13 +4,10 @@ using UnityEngine; ...@@ -4,13 +4,10 @@ using UnityEngine;
using MathNet.Numerics.LinearAlgebra; using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double;
public class Planemovement : FlatlandMovement public abstract class Planemovement : FlatlandMovement
{ {
public double starttime = 0.0f;
public Planemovement otherclock;
new void Start()
void Start()
{ {
base.Start(); base.Start();
//Renderer r = theobject.GetComponent<Renderer>(); //Renderer r = theobject.GetComponent<Renderer>();
...@@ -19,7 +16,6 @@ public class Planemovement : FlatlandMovement ...@@ -19,7 +16,6 @@ public class Planemovement : FlatlandMovement
v = new Vector3(0.0f, 0.0f, 0.0f); v = new Vector3(0.0f, 0.0f, 0.0f);
//playergamma = 1.0f; //playergamma = 1.0f;
orientation = new Vector3(0.0f, 0.0f, 1.0f); orientation = new Vector3(0.0f, 0.0f, 1.0f);
time = starttime;
gamma = 1.0f; gamma = 1.0f;
} }
...@@ -30,7 +26,7 @@ public class Planemovement : FlatlandMovement ...@@ -30,7 +26,7 @@ public class Planemovement : FlatlandMovement
} }
// For physics calcs // For physics calcs
void FixedUpdate() protected override void FixedUpdate()
{ {
base.FixedUpdate(); base.FixedUpdate();
...@@ -47,26 +43,6 @@ public class Planemovement : FlatlandMovement ...@@ -47,26 +43,6 @@ public class Planemovement : FlatlandMovement
//alpha = 4 * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + 4 * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480); //alpha = 4 * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + 4 * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
if ((levelManager.player.transform.position - transform.position).magnitude < 1f)
{
toggle = true;
}
else
{
toggle = false;
}
if (toggle && Input.GetKeyDown("g"))
{
grabbed = !grabbed;
}
if (grabbed)
{
v = levelManager.player.v;
Debug.Log("being grabbed");
}
if (alpha.magnitude > 0.0f) if (alpha.magnitude > 0.0f)
{ {
...@@ -142,30 +118,4 @@ public class Planemovement : FlatlandMovement ...@@ -142,30 +118,4 @@ public class Planemovement : FlatlandMovement
time += Time.fixedDeltaTime * (float)(levelManager.player.gamma / gamma); time += Time.fixedDeltaTime * (float)(levelManager.player.gamma / gamma);
} }
public override void OnCollisionStaychild(Collision collision)
{
base.OnCollisionStaychild(collision);
//Debug.Log("hit!");
//if(collision.transform.parent.name != "AnObject(Clone)")
// Debug.Log(collision.gameObject.name + " wow!");
if (collision.transform.parent != null)
{
var x = collision.transform.parent.gameObject.GetComponent(typeof(Planemovement)) as Planemovement;
if (x != null && x.Equals(otherclock))
{
Debug.Log("hit!");
if (Mathf.Abs((float)(otherclock.GetTime() - time)) <= 1.0f)
{
levelManager.winstate = true;
}
}
}
}
public double GetTime()
{
return time;
}
} }
...@@ -54,7 +54,7 @@ public class PathRenderer : MonoBehaviour ...@@ -54,7 +54,7 @@ public class PathRenderer : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (Input.GetMouseButtonDown(1) && levelManager.player.isInertial() && pathcreatable) if (Input.GetMouseButtonDown(1) && levelManager.player.IsInertial && pathcreatable)
{ {
RaycastHit hit1; RaycastHit hit1;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
......
...@@ -268,7 +268,7 @@ public class UIManager : MonoBehaviour ...@@ -268,7 +268,7 @@ public class UIManager : MonoBehaviour
{ {
try try
{ {
if (levelManager.player.isInertial() && pathRenderer.pathcreatable) if (levelManager.player.IsInertial && pathRenderer.pathcreatable)
{ {
RaycastHit hit; RaycastHit hit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment