Commit 8099dd9d authored by Chae Ho Shin's avatar Chae Ho Shin

added length contraction feature, minor UI and bug fixes.

parent 8dfd1a8d
...@@ -195,7 +195,7 @@ BoxCollider: ...@@ -195,7 +195,7 @@ BoxCollider:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 50038665} m_GameObject: {fileID: 50038665}
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_IsTrigger: 0 m_IsTrigger: 1
m_Enabled: 1 m_Enabled: 1
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1} m_Size: {x: 1, y: 1, z: 1}
...@@ -223,9 +223,9 @@ Transform: ...@@ -223,9 +223,9 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 50038665} m_GameObject: {fileID: 50038665}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -44.5, y: 60.9, z: 0} m_LocalPosition: {x: -44.499992, y: 60.899994, z: 0}
m_LocalScale: {x: 5, y: 5, z: 5} m_LocalScale: {x: 5, y: 5, z: 0.111111104}
m_Children: m_Children:
- {fileID: 184311043} - {fileID: 184311043}
m_Father: {fileID: 0} m_Father: {fileID: 0}
...@@ -597,11 +597,11 @@ SpriteRenderer: ...@@ -597,11 +597,11 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: -1
m_Sprite: {fileID: 21300000, guid: 42f83be37d3cdd44dbcb3669522156ac, type: 3} m_Sprite: {fileID: 21300000, guid: 42f83be37d3cdd44dbcb3669522156ac, type: 3}
m_Color: {r: 0, g: 0, b: 0, a: 1} m_Color: {r: 0, g: 0, b: 0, a: 1}
m_FlipX: 0 m_FlipX: 1
m_FlipY: 0 m_FlipY: 1
m_DrawMode: 0 m_DrawMode: 0
m_Size: {x: 19.2, y: 10.8} m_Size: {x: 19.2, y: 10.8}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
...@@ -617,11 +617,11 @@ Transform: ...@@ -617,11 +617,11 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 308816708} m_GameObject: {fileID: 308816708}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 12} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 17.44, y: 17.44, z: 17.44} m_LocalScale: {x: 400, y: 400, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &327700427 --- !u!1 &327700427
GameObject: GameObject:
...@@ -698,11 +698,11 @@ BoxCollider: ...@@ -698,11 +698,11 @@ BoxCollider:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 327700427} m_GameObject: {fileID: 327700427}
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_IsTrigger: 0 m_IsTrigger: 1
m_Enabled: 1 m_Enabled: 1
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1} m_Size: {x: 2.2959232, y: 2.2460759, z: 1}
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0.033225823, y: 0.008307076, z: 0}
--- !u!114 &327700430 --- !u!114 &327700430
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -726,9 +726,9 @@ Transform: ...@@ -726,9 +726,9 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 327700427} m_GameObject: {fileID: 327700427}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -127.2, y: 60.9, z: 0} m_LocalPosition: {x: -127.19999, y: 60.899994, z: 0}
m_LocalScale: {x: 5, y: 5, z: 5} m_LocalScale: {x: 5, y: 5, z: 0.111111104}
m_Children: m_Children:
- {fileID: 1085162589} - {fileID: 1085162589}
m_Father: {fileID: 0} m_Father: {fileID: 0}
...@@ -1015,6 +1015,97 @@ Transform: ...@@ -1015,6 +1015,97 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &630140310
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 630140311}
- component: {fileID: 630140313}
- component: {fileID: 630140312}
m_Layer: 0
m_Name: New Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &630140311
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630140310}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.111111104}
m_LocalScale: {x: 0.4854369, y: 2.0408163, z: 1}
m_Children: []
m_Father: {fileID: 1130268068}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!102 &630140312
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630140310}
m_Text: "<---1 \uAD11\uCD08--->"
m_OffsetZ: 0
m_CharacterSize: 4.2
m_LineSpacing: 1
m_Anchor: 4
m_Alignment: 0
m_TabSize: 4
m_FontSize: 0
m_FontStyle: 0
m_RichText: 1
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Color:
serializedVersion: 2
rgba: 4278190080
--- !u!23 &630140313
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630140310}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!1 &778421932 --- !u!1 &778421932
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1179,7 +1270,7 @@ LineRenderer: ...@@ -1179,7 +1270,7 @@ LineRenderer:
m_LightProbeUsage: 0 m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0 m_ReflectionProbeUsage: 0
m_RenderingLayerMask: 1 m_RenderingLayerMask: 1
m_RendererPriority: 0 m_RendererPriority: 2
m_Materials: m_Materials:
- {fileID: 2100000, guid: 695981ce54564b0439a7358d033eb87c, type: 2} - {fileID: 2100000, guid: 695981ce54564b0439a7358d033eb87c, type: 2}
m_StaticBatchInfo: m_StaticBatchInfo:
...@@ -1257,7 +1348,7 @@ LineRenderer: ...@@ -1257,7 +1348,7 @@ LineRenderer:
textureMode: 0 textureMode: 0
shadowBias: 0.5 shadowBias: 0.5
generateLightingData: 0 generateLightingData: 0
m_UseWorldSpace: 1 m_UseWorldSpace: 0
m_Loop: 0 m_Loop: 0
--- !u!4 &818789543 --- !u!4 &818789543
Transform: Transform:
...@@ -1267,11 +1358,11 @@ Transform: ...@@ -1267,11 +1358,11 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 818789540} m_GameObject: {fileID: 818789540}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &830482704 --- !u!1 &830482704
GameObject: GameObject:
...@@ -1629,9 +1720,9 @@ MonoBehaviour: ...@@ -1629,9 +1720,9 @@ MonoBehaviour:
m_HorizontalOverflow: 0 m_HorizontalOverflow: 0
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: 'New Proper Time: m_Text: 'ETA(you):
Prev Proper Time:' ETA(start frame):'
--- !u!222 &970825866 --- !u!222 &970825866
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1731,6 +1822,117 @@ MeshRenderer: ...@@ -1731,6 +1822,117 @@ MeshRenderer:
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0
--- !u!1 &1130268064
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1130268068}
- component: {fileID: 1130268067}
- component: {fileID: 1130268066}
- component: {fileID: 1130268065}
m_Layer: 0
m_Name: measuringStick
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &1130268065
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1130268064}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 42f83be37d3cdd44dbcb3669522156ac, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 2.25, y: 2.25}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!65 &1130268066
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1130268064}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &1130268067
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1130268064}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6fc00f182b978984cb6bfeb64079c14e, type: 3}
m_Name:
m_EditorClassIdentifier:
square: {fileID: 1577789449}
speedVector: {x: 0, y: 0}
gameSpeed: 0
properTime: 0
--- !u!4 &1130268068
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1130268064}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 65.6, y: -58.4, z: 0}
m_LocalScale: {x: 2.06, y: 0.49, z: 1}
m_Children:
- {fileID: 630140311}
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1214187781 --- !u!1 &1214187781
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2084,8 +2286,11 @@ MonoBehaviour: ...@@ -2084,8 +2286,11 @@ MonoBehaviour:
gameSpeed: 20 gameSpeed: 20
properTime: 0 properTime: 0
pathRenderer: {fileID: 818789542} pathRenderer: {fileID: 818789542}
pathPositionObjects: []
pathList: [] pathList: []
uiManager: {fileID: 265944882} uiManager: {fileID: 265944882}
Background: {fileID: 308816708}
backgroundSize: 400
allObjects: [] allObjects: []
attatchedObject: {fileID: 0} attatchedObject: {fileID: 0}
--- !u!212 &1577789450 --- !u!212 &1577789450
...@@ -2124,7 +2329,7 @@ SpriteRenderer: ...@@ -2124,7 +2329,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 0905f15ba4c169d478723617ce3c4ad1, type: 3} m_Sprite: {fileID: 21300000, guid: 0905f15ba4c169d478723617ce3c4ad1, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0 m_FlipX: 0
...@@ -2148,7 +2353,7 @@ Transform: ...@@ -2148,7 +2353,7 @@ Transform:
m_LocalScale: {x: 4, y: 4, z: 4} m_LocalScale: {x: 4, y: 4, z: 4}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1692443935 --- !u!1 &1692443935
GameObject: GameObject:
......
...@@ -4,13 +4,14 @@ using UnityEngine; ...@@ -4,13 +4,14 @@ using UnityEngine;
public class FlatLandObject : MonoBehaviour public class FlatLandObject : MonoBehaviour
{ {
public Square square; public Square square = null;
public Vector2 speedVector = new Vector2(0, 0); public Vector2 speedVector = new Vector2(0, 0);
public double gameSpeed = 0; public double gameSpeed = 0;
public double properTime = 0; public double properTime = 0;
void Awake() void Awake()
{ {
square.allObjects.Add(this); if(square != null)
square.allObjects.Add(this);
} }
} }
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using System; using System;
using UnityEngine.SceneManagement;
using System.Linq; using System.Linq;
public class Square : FlatLandObject public class Square : FlatLandObject
{ {
public LineRenderer pathRenderer; // About drawing paths. public LineRenderer pathRenderer; // About drawing paths.
public List<GameObject> pathPositionObjects = new List<GameObject>();
public List<Vector2> pathList = new List<Vector2>(); public List<Vector2> pathList = new List<Vector2>();
public UIManager uiManager; public UIManager uiManager;
public GameObject Background;
public float backgroundSize = 400.0f;
public List<FlatLandObject> allObjects = new List<FlatLandObject>(); // Evety FlatLandObject is automatically added with Awake(). public List<FlatLandObject> allObjects = new List<FlatLandObject>(); // Evety FlatLandObject is automatically added with Awake().
public FlatLandObject attatchedObject = null; public FlatLandObject attatchedObject = null;
...@@ -29,7 +33,7 @@ public class Square : FlatLandObject ...@@ -29,7 +33,7 @@ public class Square : FlatLandObject
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit)) // If the click was on the background if (Physics.Raycast(ray, out RaycastHit hit)) // If the click was on the background
{ {
if (Input.GetKey(KeyCode.LeftShift) && pathRenderer.GetPosition(1) != Vector3.zero) // If shift is clicked and path is already exists if (Input.GetKey(KeyCode.LeftShift) && pathPositionObjects.Count >= 1) // If shift is clicked and path is already exists
AddPath(hit.point); AddPath(hit.point);
else else
CreatePath(hit.point); CreatePath(hit.point);
...@@ -43,24 +47,106 @@ public class Square : FlatLandObject ...@@ -43,24 +47,106 @@ public class Square : FlatLandObject
Detach(); Detach();
} }
public IEnumerator MoveSquare(Vector2 destination) public IEnumerator MoveSquare(GameObject destination)
{ {
speedVector = destination - (Vector2)transform.position; Vector2 dest = new Vector2(destination.transform.position.x, destination.transform.position.y);
Vector2 start = new Vector2(transform.position.x, transform.position.y);
speedVector = dest - start;
Vector2 prevFrameSpeedVector = speedVector;
//Vector2 ndest = (Vector2)transform.position + (speedVector / (float)Constants.Gamma(gameSpeed));
Vector3 scaledVector = speedVector * Time.deltaTime; Vector3 scaledVector = speedVector * Time.deltaTime;
while (speedVector.x * (destination.x - transform.position.x) > 0 || speedVector.y * (destination.y - transform.position.y) > 0) LengthContraction(scaledVector);
dest = new Vector2(destination.transform.position.x, destination.transform.position.y);
start = new Vector2(transform.position.x, transform.position.y);
speedVector = dest - start;
scaledVector = speedVector * Time.deltaTime;
while (speedVector.x * (destination.transform.position.x - transform.position.x) > 0 || speedVector.y * (destination.transform.position.y - transform.position.y) > 0)
{ {
transform.position += scaledVector; transform.position += scaledVector;
if (attatchedObject != null) if (attatchedObject != null)
attatchedObject.gameObject.transform.position += scaledVector; attatchedObject.gameObject.transform.position += scaledVector;
yield return null; yield return null;
} }
Background.transform.localScale = new Vector3(backgroundSize, backgroundSize, 1.0F);
Background.transform.position = new Vector3(Background.transform.localPosition.x, Background.transform.localPosition.y, 0.0f);
//RemoveFromBackground();
Background.transform.DetachChildren();
//pathRenderer.transform.position = new Vector3(0.0f, 0.0f, -2.0f);
Background.transform.position = destination.transform.position;
//Background.transform.localPosition += (Vector3)speedVector;
//Background.transform.localPosition += (Vector3)speedVector;
AddtoBackground();
Background.transform.position = transform.position;
Background.transform.position = new Vector3(Background.transform.position.x, Background.transform.position.y, 0.0f);
//Background.transform.DetachChildren();
//Background.transform.localEulerAngles = new Vector3(0.0F, 0.0F, 0.0F);
//Background.transform.LookAt(-Vector3.forward);
//AddtoBackground();
//RemoveFromBackground();
Background.transform.DetachChildren();
Background.transform.position = new Vector3(Background.transform.position.x, Background.transform.position.y, 0.0f);
//pathRenderer.transform.position = new Vector3(0.0f, 0.0f, -2.0f);
yield return null;
}
public void LengthContraction(Vector3 scaledVector) // length contraction - find all flatlandobjects not grabbed by the square, add them to the rotated background and squeeze
{
//Background.transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, Background.transform.localPosition.z);
Background.transform.rotation = Quaternion.LookRotation(Vector3.forward, scaledVector);
//Background.transform.LookAt(new Vector3(0.0f,0.0f,1.0f),scaledVector);
AddtoBackground();
Background.transform.localScale = new Vector3(backgroundSize, (float)(1 / Constants.Gamma(gameSpeed)) * backgroundSize, 1.0F);
}
public void AddtoBackground()
{
List<GameObject> rootObjects = new List<GameObject>();
Scene scene = SceneManager.GetActiveScene();
scene.GetRootGameObjects(rootObjects);
foreach (GameObject anobject in rootObjects)
{
if (anobject.GetComponent<FlatLandObject>() != null && anobject.GetComponent<Square>() == null)
{
if (attatchedObject != null && anobject == attatchedObject.gameObject)
continue;
else
{
anobject.transform.parent = Background.transform;
}
}
}
pathRenderer.transform.parent = Background.transform;
}
public void RemoveFromBackground()
{
foreach(Transform t in Background.transform)
{
Vector3 realposition = t.position;
Quaternion realrotation = t.rotation;
Vector3 realscale = t.lossyScale;
Transform a = t;
t.parent = null;
a.localPosition = realposition;
a.localRotation = realrotation;
a.localScale = realscale;
}
} }
public void CreatePath(Vector3 point) // Creates the fitst path, and updates Proper Time UI. public void CreatePath(Vector3 point) // Creates the fitst path, and updates Proper Time UI.
{ {
ResetPaths();
pathRenderer.positionCount = 2; pathRenderer.positionCount = 2;
pathRenderer.SetPositions(new Vector3[] { transform.position, point }); pathRenderer.SetPositions(new Vector3[] { transform.position, point });
pathRenderer.material.color = Color.green;
GameObject wow = new GameObject("Point1"); //turn the destination point into a gameobject for length contraction scaling
wow.transform.parent = null;
wow.transform.localPosition = new Vector3(point.x, point.y, 0.0f);
wow.AddComponent<FlatLandObject>();
pathPositionObjects.Add(wow);
uiManager.UpdateUI(); uiManager.UpdateUI();
} }
...@@ -68,6 +154,12 @@ public class Square : FlatLandObject ...@@ -68,6 +154,12 @@ public class Square : FlatLandObject
{ {
pathRenderer.positionCount++; pathRenderer.positionCount++;
pathRenderer.SetPosition(pathRenderer.positionCount - 1, point); pathRenderer.SetPosition(pathRenderer.positionCount - 1, point);
GameObject wow = new GameObject("Point" + (pathRenderer.positionCount - 1), typeof(FlatLandObject));
wow.transform.parent = null;
wow.transform.localPosition = new Vector3(point.x, point.y, 0.0f);
pathPositionObjects.Add(wow);
uiManager.UpdateUI(); uiManager.UpdateUI();
} }
...@@ -79,11 +171,18 @@ public class Square : FlatLandObject ...@@ -79,11 +171,18 @@ public class Square : FlatLandObject
public IEnumerator _StartMovingPath() public IEnumerator _StartMovingPath()
{ {
Vector3[] tomoveList = new Vector3[pathRenderer.positionCount]; //Vector3[] tomoveList = new Vector3[pathRenderer.positionCount];
pathRenderer.GetPositions(tomoveList); //pathRenderer.GetPositions(tomoveList);
for(int i = 1; i < pathRenderer.positionCount; i++) //Vector3[] tomoveList = new Vector3[pathRenderer.positionCount - 1];
//for(int i = 1; i < pathRenderer.positionCount; i++)
//{
//yield return StartCoroutine(MoveSquare(tomoveList[i]));
//}
foreach(GameObject wow in pathPositionObjects)
{ {
yield return StartCoroutine(MoveSquare(tomoveList[i])); yield return StartCoroutine(MoveSquare(wow));
//Background.transform.position = transform.position;
} }
AddTimes(); AddTimes();
...@@ -96,12 +195,18 @@ public class Square : FlatLandObject ...@@ -96,12 +195,18 @@ public class Square : FlatLandObject
{ {
pathRenderer.positionCount = 2; pathRenderer.positionCount = 2;
pathRenderer.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero }); pathRenderer.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero });
foreach(GameObject j in pathPositionObjects)
{
Destroy(j);
}
pathPositionObjects = new List<GameObject>();
pathRenderer.transform.localPosition = Vector3.zero;
} }
public Vector2 getNthPath(int n) // returns movement vector stored in path renderer by index. public Vector2 getNthPath(int n) // returns movement vector stored in path renderer by index.
{ {
if (n >= pathRenderer.positionCount) if (n >= pathRenderer.positionCount)
throw new InvalidOperationException(n + "th path is not stored."); throw new InvalidOperationException(n + "the path is not stored.");
return pathRenderer.GetPosition(n + 1) - pathRenderer.GetPosition(n); return pathRenderer.GetPosition(n + 1) - pathRenderer.GetPosition(n);
} }
...@@ -132,7 +237,16 @@ public class Square : FlatLandObject ...@@ -132,7 +237,16 @@ public class Square : FlatLandObject
var lst = Physics.OverlapSphere(transform.position, 10); var lst = Physics.OverlapSphere(transform.position, 10);
if (lst.Length > 0) if (lst.Length > 0)
attatchedObject = lst[0].gameObject.GetComponent<FlatLandObject>(); {
foreach(Collider thing in lst)
{
if (thing.gameObject.GetComponent<FlatLandObject>() != null)
{
attatchedObject = thing.gameObject.GetComponent<FlatLandObject>();
break;
}
}
}
} }
public void Detach() public void Detach()
......
...@@ -10,24 +10,36 @@ public class UIManager : MonoBehaviour ...@@ -10,24 +10,36 @@ public class UIManager : MonoBehaviour
public Square square; public Square square;
public FlatLandObject clock1, clock2; public FlatLandObject clock1, clock2;
public GameObject victoryScreen; public GameObject victoryScreen;
float curZoomPos = 95.0f;
public void UpdateUI() // it just updates UI. public void UpdateUI() // it just updates UI.
{ {
string newPropertime, prevPropertime; double newPropertime, prevPropertime;
currentSpeed.text = "Current Speed : " + (square.gameSpeed / Constants.c).ToString("F2") + "c"; currentSpeed.text = "Current Speed : " + (square.gameSpeed / Constants.c).ToString("F2") + "c";
prevPropertime = square.CalculateEntireMovingTime().ToString(); prevPropertime = square.CalculateEntireMovingTime();
newPropertime = (square.CalculateEntireMovingTime() / Constants.Gamma(square.gameSpeed)).ToString(); newPropertime = (square.CalculateEntireMovingTime() / Constants.Gamma(square.gameSpeed));
properTime.text = "New Proper Time : +" + newPropertime + " seconds\nPrev Proper Time : +" + prevPropertime + " seconds"; properTime.text = "ETA(you) : " + newPropertime.ToString("+0;-#") + " seconds\nETA(start frame) : " + prevPropertime.ToString("+0;-#") + " seconds\nΔt : " + (newPropertime - prevPropertime).ToString("+0;-#") + " seconds";
clockText.text = "Clock1 : " + clock1.properTime + " second\nClock2 : " + clock2.properTime + " second"; clockText.text = "Clock1 : " + clock1.properTime + " seconds\nClock2 : " + clock2.properTime + " seconds";
}
public void Update()
{
float y = Input.mouseScrollDelta.y;
curZoomPos -= y*20;
curZoomPos = Mathf.Clamp(curZoomPos, 40f, 400f);
// Makes the actual change to Field Of View
Camera.main.orthographicSize = curZoomPos;
} }
public void CheckVictory() public void CheckVictory()
{ {
if ((clock1.transform.position - clock2.transform.position).sqrMagnitude < 10 && Mathf.Abs((float)(clock1.properTime - clock2.properTime)) < 1) if ((clock1.transform.position - clock2.transform.position).sqrMagnitude < 20 && Mathf.Abs((float)(clock1.properTime - clock2.properTime)) < 1)
victoryScreen.SetActive(true); victoryScreen.SetActive(true);
} }
} }
...@@ -31,6 +31,9 @@ GraphicsSettings: ...@@ -31,6 +31,9 @@ GraphicsSettings:
m_AlwaysIncludedShaders: m_AlwaysIncludedShaders:
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: [] m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0} type: 0}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
UnityConnectSettings: UnityConnectSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 1 serializedVersion: 1
m_Enabled: 0 m_Enabled: 1
m_TestMode: 0 m_TestMode: 0
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
......
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