Browse Source

Trap scripts finished - for now - starting testing and will adjust if needed.

Changed the prefab for the cannon to instantiate the shooting object each time, and a bool to specify if it will push characters left or right, made it easier for figuring it out and calling the right coroutine
added coroutines to character script
Josh_Dev_branch
ClairePeta 4 years ago
parent
commit
3ed20990ef
9 changed files with 280 additions and 159 deletions
  1. +108
    -0
      Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab
  2. +2
    -3
      Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab.meta
  3. +4
    -68
      Assets/Prefabs/Traps/CrushingBoulder.prefab
  4. +17
    -17
      Assets/Prefabs/Traps/FloatingOnWater.prefab
  5. +6
    -67
      Assets/Prefabs/Traps/ShootingCannon.prefab
  6. +61
    -0
      Assets/Scripts/Character.cs
  7. +28
    -1
      Assets/Scripts/Traps/ConveyorBelt.cs
  8. +13
    -2
      Assets/Scripts/Traps/FloatingOnWater.cs
  9. +41
    -1
      Assets/Scripts/Traps/ShootingCannon.cs

+ 108
- 0
Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab View File

@ -0,0 +1,108 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3506936643819969965
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4787400513692267026}
m_Layer: 0
m_Name: Cannon_Shooting_Object
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4787400513692267026
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3506936643819969965}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4028070546779697659}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &4032901744580679509
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 4787400513692267026}
m_Modifications:
- target: {fileID: 1229707520659320, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_Name
value: Cannon_Shooting
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalScale.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalScale.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalScale.z
value: 0.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
--- !u!4 &4028070546779697659 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e,
type: 3}
m_PrefabInstance: {fileID: 4032901744580679509}
m_PrefabAsset: {fileID: 0}

Assets/Plugins/IngameDebugConsole/Prefabs.meta → Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab.meta View File

@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: 7dbc36665bc0d684db9a4447e27a7a4b
folderAsset: yes
DefaultImporter:
guid: e8cf547bc36bd094f860f652fbe08047
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:

+ 4
- 68
Assets/Prefabs/Traps/CrushingBoulder.prefab View File

@ -19,7 +19,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &6745622315908332759
RectTransform:
m_ObjectHideFlags: 0
@ -237,7 +237,6 @@ Transform:
m_Children:
- {fileID: 6741087515541790872}
- {fileID: 6745622315908332759}
- {fileID: 6742653090089018601}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -253,76 +252,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 87ae70f1ec0c67743923bd4a83ee85d8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &6745622315586474845
--- !u!1001 &6745622316608603784
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 6745622317302131140}
m_Modifications:
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1141756196039588, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
- target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_Name
value: Cube_GroundWGrass (9)
value: Rock_2 (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
--- !u!4 &6742653090089018601 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291,
type: 3}
m_PrefabInstance: {fileID: 6745622315586474845}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6745622316608603784
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 6745622317302131140}
m_Modifications:
- target: {fileID: 4614242176542224, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -375,10 +315,6 @@ PrefabInstance:
propertyPath: m_LocalScale.z
value: 1.2289
objectReference: {fileID: 0}
- target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_Name
value: Rock_2 (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
--- !u!4 &6741087515541790872 stripped

+ 17
- 17
Assets/Prefabs/Traps/FloatingOnWater.prefab View File

@ -49,7 +49,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &7729055451593449897
Transform:
m_ObjectHideFlags: 0
@ -87,6 +87,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 8460854531351183923}
m_Modifications:
- target: {fileID: 1689483960513604, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_Name
value: Flower4_2
objectReference: {fileID: 0}
- target: {fileID: 4599309359665518, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -139,10 +143,6 @@ PrefabInstance:
propertyPath: m_LocalScale.z
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1689483960513604, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_Name
value: Flower4_2
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
--- !u!4 &7432977658103809198 stripped
@ -158,6 +158,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 8460854531351183923}
m_Modifications:
- target: {fileID: 1689483960513604, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_Name
value: Flower4_2 (1)
objectReference: {fileID: 0}
- target: {fileID: 4599309359665518, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -214,10 +218,6 @@ PrefabInstance:
propertyPath: m_LocalScale.z
value: 1.1
objectReference: {fileID: 0}
- target: {fileID: 1689483960513604, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_Name
value: Flower4_2 (1)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
--- !u!4 &7432977658097158566 stripped
@ -233,6 +233,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 7729055451593449897}
m_Modifications:
- target: {fileID: 1379645051613606, guid: 2cb12feb62290af4ab4634e7ac62b956, type: 3}
propertyPath: m_Name
value: Cube_Water
objectReference: {fileID: 0}
- target: {fileID: 4967946560886230, guid: 2cb12feb62290af4ab4634e7ac62b956, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -277,10 +281,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1379645051613606, guid: 2cb12feb62290af4ab4634e7ac62b956, type: 3}
propertyPath: m_Name
value: Cube_Water
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2cb12feb62290af4ab4634e7ac62b956, type: 3}
--- !u!4 &7432853164086773831 stripped
@ -296,6 +296,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 8460854531351183923}
m_Modifications:
- target: {fileID: 1689483960513604, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_Name
value: Flower4_2 (2)
objectReference: {fileID: 0}
- target: {fileID: 4599309359665518, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -352,10 +356,6 @@ PrefabInstance:
propertyPath: m_LocalScale.z
value: 0.6
objectReference: {fileID: 0}
- target: {fileID: 1689483960513604, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
propertyPath: m_Name
value: Flower4_2 (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 57ed0c24aae4edc4495ddde07d66cf23, type: 3}
--- !u!4 &7432977657908968882 stripped

+ 6
- 67
Assets/Prefabs/Traps/ShootingCannon.prefab View File

@ -19,7 +19,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1907555562
RectTransform:
m_ObjectHideFlags: 0
@ -32,7 +32,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4407065910963968002}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -237,7 +237,6 @@ Transform:
m_Children:
- {fileID: 4411312180479633393}
- {fileID: 4411389509623840118}
- {fileID: 4406490330407094211}
- {fileID: 1907555562}
m_Father: {fileID: 0}
m_RootOrder: 0
@ -254,6 +253,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 44366bd8a25270844bdd9a5db9f2b0e0, type: 3}
m_Name:
m_EditorClassIdentifier:
shootingRight: 0
shootingObject: {fileID: 0}
clientData: {fileID: 0}
--- !u!65 &7713460145294617833
BoxCollider:
m_ObjectHideFlags: 0
@ -267,69 +269,6 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 0.24999993, y: 0.2500002, z: 0.53749573}
m_Center: {x: 0, y: 0, z: 0}
--- !u!1001 &4407065910499815543
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 4407065910963968002}
m_Modifications:
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1141756196039588, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
propertyPath: m_Name
value: Cube_GroundWGrass (10)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d7698c69246c64044ab2a94628bf0291, type: 3}
--- !u!4 &4406490330407094211 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4490970058520500, guid: d7698c69246c64044ab2a94628bf0291,
type: 3}
m_PrefabInstance: {fileID: 4407065910499815543}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &4407065911164666478
PrefabInstance:
m_ObjectHideFlags: 0
@ -414,7 +353,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalPosition.z
value: 0.825
value: 0.25
objectReference: {fileID: 0}
- target: {fileID: 4831352554563246, guid: 601c1b79e12ee6f428da0cdfc7412e9e, type: 3}
propertyPath: m_LocalRotation.x

+ 61
- 0
Assets/Scripts/Character.cs View File

@ -130,6 +130,53 @@ public class Character : MonoBehaviour
transform.position = Target.VisualPosition;
}
IEnumerator MoveConveyorCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, Target.VisualPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = Target.VisualPosition;
}
IEnumerator PushLeftCoroutine(Transform Current, float time)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
Vector3 endPosition = new Vector3(Current.position.x - 1, Current.position.y, Current.position.z);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = endPosition;
}
IEnumerator PushRightCoroutine(Transform Current, float time)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
Vector3 endPosition = new Vector3(Current.position.x + 1, Current.position.y, Current.position.z);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = endPosition;
}
IEnumerator MoveDownCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
@ -201,6 +248,20 @@ public class Character : MonoBehaviour
//transform.position = CurrentBlock.VisualPosition;
}
public void conveyorMove(Direction direction, float speed)
{
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
StartCoroutine(MoveConveyorCoroutine(_currentBlock, transform, speed, 0.3f));
}
public void CannonRMove(Direction direction, float speed)
{
StartCoroutine(PushRightCoroutine(transform, speed));
}
public void CannonLMove(Direction direction, float speed)
{
StartCoroutine(PushLeftCoroutine(transform, speed));
}
/// <summary>
/// Upon collision with a floating block, collect its
/// Upon collision with the end portal, end of level

+ 28
- 1
Assets/Scripts/Traps/ConveyorBelt.cs View File

@ -1,11 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
public class ConveyorBelt : MonoBehaviour
{
public ConnectedClients clientData;
bool characterOnBelt = false;
GameObject player;
string charname;
private List<string> Names;
private void Start()
{
for (int i = 0; i < clientData.AllClients.Count; i++)
{
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
}
}
void OnTriggerEnter(Collider other)
{
for (int i = 0; i < Names.Count; i++)
{
if (other.gameObject.name == Names[i])
{
characterOnBelt = true;
charname = other.gameObject.name;
}
}
}
public void Animate()
{
Debug.Log("abs");
player = GameObject.Find(charname);
player.GetComponent<Character>().conveyorMove(Direction.Forward, 1.0f);
}
}

+ 13
- 2
Assets/Scripts/Traps/FloatingOnWater.cs View File

@ -9,6 +9,8 @@ public class FloatingOnWater : MonoBehaviour
public ConnectedClients clientData;
private List<string> Names;
public GameObject lilypad;
GameObject player;
string charName;
private void Start()
{
@ -24,6 +26,7 @@ public class FloatingOnWater : MonoBehaviour
if (other.gameObject.name == Names[i])
{
characterInWater = true;
charName = other.gameObject.name;
}
}
}
@ -32,19 +35,27 @@ public class FloatingOnWater : MonoBehaviour
{
float elapsedTime = 0;
Vector3 startPosition = lilypad.transform.position;
Vector3 charStartPosition = player.transform.position;
Vector3 charEndPosition = new Vector3(player.transform.position.x, 1, player.transform.position.z);
float time = 0.8f;
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
lilypad.transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
player.transform.position = Vector3.Lerp(charStartPosition, charEndPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
player.transform.position = charEndPosition;
lilypad.transform.position = endPosition;
}
public void Animate()
{
StartCoroutine(FloatSinkCoroutine(new Vector3(0, 1, 0)));
if(characterInWater == true)
{
player = GameObject.Find(charName);
StartCoroutine(FloatSinkCoroutine(new Vector3(0, 1, 0)));
}
}
public void returnToPosition()
{

+ 41
- 1
Assets/Scripts/Traps/ShootingCannon.cs View File

@ -1,11 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
public class ShootingCannon : MonoBehaviour
{
public bool shootingRight;
public GameObject shootingObject;
public ConnectedClients clientData;
bool characterOnBelt = false;
GameObject player;
string charname;
private List<string> Names;
private void Start()
{
for (int i = 0; i < clientData.AllClients.Count; i++)
{
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
}
}
void OnTriggerEnter(Collider other)
{
for (int i = 0; i < Names.Count; i++)
{
if (other.gameObject.name == Names[i])
{
characterOnBelt = true;
charname = other.gameObject.name;
}
}
}
public void Animate()
{
Debug.Log("abs");
Vector3 position = new Vector3(0.0f, 1.338f, 0.25f);
GameObject shot = Instantiate(shootingObject, position, Quaternion.identity);
player = GameObject.Find(charname);
if(shootingRight == true)
{
player.GetComponent<Character>().CannonRMove(Direction.Forward, 1.0f);
}
else
{
player.GetComponent<Character>().CannonLMove(Direction.Forward, 1.0f);
}
}
}

Loading…
Cancel
Save