Commit b4184cd7 authored by Chae Ho Shin's avatar Chae Ho Shin

working demo of model(proto level)

parent d689c27e
This diff is collapsed.
......@@ -37,7 +37,7 @@ public class CameraMovement : MonoBehaviour
transform.rotation = Quaternion.LookRotation(-vt, newforward);
thecamera.orthographicSize = 5.0f * ((float)Levelmanager.player.gamma);
thecamera.orthographicSize = 10.0f * ((float)Levelmanager.player.gamma);
aspect = 16.0f / (9.0f * (Levelmanager.player.gamma));
......
......@@ -75,7 +75,7 @@ public class ExtrudedMesh : MonoBehaviour
DestroyImmediate(clone.transform.GetChild(1).gameObject);
}
DestroyImmediate(clone.GetComponentInChildren<ExtrudedMesh>());
clone.GetComponentInChildren<MeshCollider>().convex = true;
clone.GetComponentInChildren<MeshCollider>().convex = false;
clone.GetComponentInChildren<MeshCollider>().sharedMesh = clone.GetComponentInChildren<MeshFilter>().mesh;
clone.transform.GetChild(0).gameObject.AddComponent<RuntimeCSGFlatlandObject>();
clone.layer = 8;
......@@ -167,4 +167,12 @@ public class ExtrudedMesh : MonoBehaviour
}
public void OnCollisionStay(Collision collision)
{
if (transform.parent.GetComponent(typeof(Planemovement)) == null)
return;
else
transform.parent.GetComponent<Planemovement>().OnCollisionStaychild(collision);
}
}
......@@ -7,10 +7,11 @@ public class LevelManager : MonoBehaviour
public double gamma;
public PlayerMovement player;
public bool winstate = false;
// Start is called before the first frame update
void Start()
{
winstate = false;
}
// Update is called once per frame
......
......@@ -4,17 +4,23 @@ using UnityEngine;
public class Planemovement : MonoBehaviour
{
//bool toggle = true;
bool toggle = false;
bool grabbed = false;
int cnt = 0;
double beta = 0.5f; // v/c
Vector3 alpha = new Vector3(0.1f, 0.0f, 0.0f); // proper acceleration
Vector3 v;
public LevelManager Levelmanager;
public double playergamma;
public double starttime = 0.0f;
Vector3 orientation;
double time = 0.0f;
// Start is called before the first frame update
public GameObject theobject;
public Planemovement otherclock;
void Start()
{
......@@ -22,7 +28,9 @@ public class Planemovement : MonoBehaviour
//Color materialColor = r.material.color;
//r.material.color = Color.clear;
v = new Vector3(0.0f, 0.0f, 0.0f);
playergamma = 1.0f;
//playergamma = 1.0f;
orientation = new Vector3(0.0f, 0.0f, 1.0f);
time = starttime;
}
// Update is called once per frame
......@@ -32,22 +40,50 @@ public class Planemovement : MonoBehaviour
{
var prevup = transform.up;
var prevfor = transform.forward;
var prevorient = orientation;
transform.Translate(Vector3.up * Time.fixedDeltaTime * (float)Levelmanager.player.gamma, Space.World); // move up by 1 second
//cnt++;
//if (cnt % 480 == 0)
//{
// cnt = 0;
//}
cnt++;
if (cnt % 480 == 0)
{
cnt = 0;
}
//transform.Translate(Vector3.forward * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.forward * Mathf.Cos(2*Mathf.PI*cnt/480) * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480) * Time.fixedDeltaTime, Space.World);
//orientation = (float)beta * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + (float)beta * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
//v = (float)beta * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + (float)beta * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
//v = alpha.normalized * (alpha.magnitude * Time.time / Mathf.Sqrt(1.0f+(alpha.magnitude * Time.time)*(alpha.magnitude * Time.time)));
//v = new Vector3(0, 0, 0);
if((Levelmanager.player.transform.position - transform.position).magnitude < 0.5f)
{
toggle = true;
}
else
{
toggle = false;
}
if(toggle && Input.GetKeyDown("g"))
{
grabbed = !grabbed;
}
if(grabbed)
{
v = Levelmanager.player.v;
Debug.Log("being grabbed");
}
else
{
v = new Vector3(0, 0, 0);
}
beta = v.magnitude / 1.0f;
double gamma = 1.0f / Mathf.Sqrt(1.0f - (float)(beta*beta));
......@@ -67,6 +103,7 @@ public class Planemovement : MonoBehaviour
theobject.transform.up = vt;
theobject.transform.parent = null;
theobject.transform.RotateAround(theobject.transform.position, vt, Vector3.Angle(prevorient,orientation));
Vector3 newforward = new Vector3(vt.y * (v.x/v.magnitude),Mathf.Sqrt(vt.x * vt.x + vt.z *vt.z), vt.y * (v.z / v.magnitude));
......@@ -76,5 +113,29 @@ public class Planemovement : MonoBehaviour
transform.localScale = new Vector3(1.0f, 1.0f, (float)gamma); // scale x' axis
time += Time.fixedDeltaTime * (float)Levelmanager.player.gamma / (float)gamma;
}
public void OnCollisionStaychild(Collision collision)
{
//Debug.Log("hit!");
//if(collision.transform.parent.name != "AnObject(Clone)")
// Debug.Log(collision.gameObject.name + " wow!");
if (collision.transform.parent != null)
{
if (collision.transform.parent.gameObject.Equals(otherclock))
{
Debug.Log("hit!");
if (Mathf.Abs((float)(otherclock.GetTime() - time)) < 1.0f)
{
Levelmanager.winstate = true;
}
}
}
}
public double GetTime()
{
return time;
}
}
......@@ -10,6 +10,9 @@ public class PlayerMovement : MonoBehaviour
public Vector3 v = new Vector3(0.0f, 0.0f, 0.0f);
public double gamma = 1.0f;
public GameObject theobject;
public Vector3 orientation = new Vector3(0.0f, 0.0f, 0.0f);
public double time = 0.0f;
int cnt = 0;
// Start is called before the first frame update
void Start()
......@@ -17,6 +20,8 @@ public class PlayerMovement : MonoBehaviour
v = new Vector3(0.0f, 0.0f, 0.0f);
gamma = 1.0f;
cnt = 0;
orientation = new Vector3(0.0f, 0.0f, 1.0f);
time = 0.0f;
}
// Update is called once per frame
......@@ -24,6 +29,7 @@ public class PlayerMovement : MonoBehaviour
{
var prevup = transform.up;
var prevfor = transform.forward;
var prevorient = orientation;
transform.Translate(Vector3.up * Time.fixedDeltaTime * (float)gamma, Space.World); // move up by 1 second
cnt++;
if (cnt % 480 == 0)
......@@ -33,9 +39,26 @@ public class PlayerMovement : MonoBehaviour
//transform.Translate(Vector3.forward * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.forward * Mathf.Cos(2*Mathf.PI*cnt/480) * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480) * Time.fixedDeltaTime, Space.World);
//orientation = Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
//v = (float)beta * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + (float)beta * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
v = alpha.normalized * (alpha.magnitude * Time.time / Mathf.Sqrt(1.0f + (alpha.magnitude * Time.time) * (alpha.magnitude * Time.time)));
//v = alpha.normalized * (alpha.magnitude * Time.time / Mathf.Sqrt(1.0f + (alpha.magnitude * Time.time) * (alpha.magnitude * Time.time)));
v = new Vector3(0, 0, 0);
if(Input.GetKey("w"))
{
v += Vector3.forward * 0.8f;
}
else if(Input.GetKey("a"))
{
v += Vector3.left * 0.8f;
}
else if(Input.GetKey("s"))
{
v -= Vector3.forward * 0.8f;
}
else if(Input.GetKey("d"))
{
v += Vector3.right * 0.8f;
}
beta = v.magnitude / 1.0f;
......@@ -53,9 +76,14 @@ public class PlayerMovement : MonoBehaviour
transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); // release child to change x'-axis scale
theobject.transform.up = vt;
//theobject.transform.up = vt;
var neworientation = (Quaternion.FromToRotation(Vector3.up, vt)) * orientation;
theobject.transform.rotation = Quaternion.LookRotation(neworientation, vt);
theobject.transform.parent = null;
//theobject.transform.RotateAround(theobject.transform.position, vt, Vector3.Angle(prevorient, orientation));
Vector3 newforward = new Vector3(vt.y * (v.x / v.magnitude), Mathf.Sqrt(vt.x * vt.x + vt.z * vt.z), vt.y * (v.z / v.magnitude));
......@@ -64,5 +92,8 @@ public class PlayerMovement : MonoBehaviour
theobject.transform.parent = transform;
transform.localScale = new Vector3(1.0f, 1.0f, (float)gamma); // scale x'-axis scale (distance dilation)
time += Time.fixedDeltaTime;
}
}
......@@ -11,7 +11,7 @@ public class RuntimeCSGFlatlandObject : MonoBehaviour
int cnt = 0;
public CSG csg;
//public CSG csg;
// Start is called before the first frame update
void Start()
{
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScreenMovement : MonoBehaviour
{
public LevelManager Levelmanager;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void FixedUpdate()
{
var v = Levelmanager.player.v;
transform.rotation = Quaternion.AngleAxis(Vector3.SignedAngle(v,Vector3.forward, Vector3.up), Vector3.forward);
}
}
fileFormatVersion: 2
guid: 4e0af0ca58f3ba4479655495ab6e9bef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -11,7 +11,14 @@ public class UIManager : MonoBehaviour
Square square;
public GameObject canvas;
public Text mytime;
public Planemovement clock1;
public Planemovement clock2;
public Text clock1time;
public Text clock2time;
public Text wintext;
public GameObject _pathUI;
public LevelManager Levelmanager;
private int prevSelectPathNum = -1;
// Start is called before the first frame update
......@@ -23,6 +30,13 @@ public class UIManager : MonoBehaviour
// Update is called once per frame
void Update()
{
mytime.text = Levelmanager.player.time.ToString() + " s";
clock1time.text = clock1.GetTime().ToString() + " s";
clock2time.text = clock2.GetTime().ToString() + " s";
if(Levelmanager.winstate)
{
wintext.enabled = true;
}
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
......
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