Browse Source

Separated the traps that need to be called after each turn and then after each round in the traps script

Tested it in the racetrack scene it gets a list of all the objects at runtime so when the functions are called will trigger them one at a time.
Also got the characters moving correctly with the conveyor belts and the shooting cannon.
Josh_Dev_branch
ClairePeta 5 years ago
parent
commit
27ef03ad62
12 changed files with 237 additions and 110 deletions
  1. +1
    -1
      Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab
  2. +12
    -10
      Assets/Prefabs/Traps/CrushingBoulder.prefab
  3. +45
    -32
      Assets/Prefabs/Traps/InGroundTrap.prefab
  4. +6
    -4
      Assets/Prefabs/Traps/ShootingCannon.prefab
  5. +2
    -2
      Assets/Scenes/RaceTrack 4-player alpha.unity
  6. +2
    -2
      Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity
  7. +59
    -12
      Assets/Scripts/Character.cs
  8. +7
    -7
      Assets/Scripts/Traps/CannonShot.cs
  9. +14
    -11
      Assets/Scripts/Traps/ConveyorBelt.cs
  10. +16
    -1
      Assets/Scripts/Traps/CrushingBoulder.cs
  11. +23
    -9
      Assets/Scripts/Traps/ShootingCannon.cs
  12. +50
    -19
      Assets/Scripts/Traps/Traps.cs

+ 1
- 1
Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab View File

@ -46,7 +46,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 20a19dbbf99278d49837cc757add262e, type: 3}
m_Name:
m_EditorClassIdentifier:
shootingRight: 0
shootingRight: 1
clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2}
Names: []
--- !u!54 &3386372059152676518

+ 12
- 10
Assets/Prefabs/Traps/CrushingBoulder.prefab View File

@ -19,7 +19,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &6745622315908332759
RectTransform:
m_ObjectHideFlags: 0
@ -112,7 +112,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_text: 3
m_text: 5
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
@ -254,6 +254,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
triggeranimate: 0
triggeranimate1: 0
countdowntimer: 3
counter: {fileID: 6745622315908332755}
--- !u!1001 &6745622316608603784
PrefabInstance:
m_ObjectHideFlags: 0
@ -261,6 +263,14 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 6745622317302131140}
m_Modifications:
- target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_Name
value: Rock_2 (2)
objectReference: {fileID: 0}
- target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_StaticEditorFlags
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4614242176542224, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -313,14 +323,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}
- target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
propertyPath: m_StaticEditorFlags
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3}
--- !u!4 &6741087515541790872 stripped

+ 45
- 32
Assets/Prefabs/Traps/InGroundTrap.prefab View File

@ -9,6 +9,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3281312547625224782}
- component: {fileID: 666895481879696395}
m_Layer: 0
m_Name: InGroundTrap
m_TagString: Untagged
@ -35,6 +36,18 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &666895481879696395
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3281312547625224785}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 90d16cd20b1d52149ae6b3d4c15c79db, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1063799847781320221
PrefabInstance:
m_ObjectHideFlags: 0
@ -115,6 +128,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3280778023726093299}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -159,10 +176,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 180
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!1001 &3281312546064687605
@ -172,6 +185,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3281312547625224782}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (3)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -220,10 +237,6 @@ PrefabInstance:
propertyPath: m_LocalScale.x
value: 0.9
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (3)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!4 &3280778022459986741 stripped
@ -239,6 +252,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3280778023471378434}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -283,10 +300,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 180
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!1001 &3281312547073059897
@ -296,6 +309,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3280778023765625369}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -340,10 +357,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 180
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!1001 &3281312547210150594
@ -353,6 +366,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3281312547625224782}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: -0.4
@ -401,10 +418,6 @@ PrefabInstance:
propertyPath: m_LocalScale.x
value: 0.90000045
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!4 &3280778023471378434 stripped
@ -420,6 +433,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3280778022459986741}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -464,10 +481,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 180
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (4)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!1001 &3281312547451467993
@ -477,6 +490,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3281312547625224782}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (1)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
@ -525,10 +542,6 @@ PrefabInstance:
propertyPath: m_LocalScale.x
value: 0.9
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (1)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!4 &3280778023765625369 stripped
@ -544,6 +557,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3281312547625224782}
m_Modifications:
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (2)
objectReference: {fileID: 0}
- target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_LocalPosition.x
value: 0.4
@ -592,10 +609,6 @@ PrefabInstance:
propertyPath: m_LocalScale.x
value: 0.90000045
objectReference: {fileID: 0}
- target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
propertyPath: m_Name
value: FanceWooden2 (2)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3}
--- !u!4 &3280778023726093299 stripped

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

@ -19,7 +19,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1907555562
RectTransform:
m_ObjectHideFlags: 0
@ -112,7 +112,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_text: 3
m_text: 5
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
@ -189,11 +189,11 @@ MonoBehaviour:
lineCount: 1
pageCount: 1
materialCount: 1
m_havePropertiesChanged: 1
m_havePropertiesChanged: 0
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_isInputParsingRequired: 1
m_isInputParsingRequired: 0
m_inputSource: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 1907555566}
@ -258,6 +258,8 @@ MonoBehaviour:
shootingObject: {fileID: 3506936643819969965, guid: e8cf547bc36bd094f860f652fbe08047,
type: 3}
spawnLocation: {fileID: 4411312180479633393}
counter: {fileID: 1907555563}
countdowntimer: 3
--- !u!65 &7713460145294617833
BoxCollider:
m_ObjectHideFlags: 0

+ 2
- 2
Assets/Scenes/RaceTrack 4-player alpha.unity View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8a88996c6bfd31688f0b46e64f918125b639084deb91f199c306dda93b01aca4
size 2624360
oid sha256:7be58d4f752cf70994f98e1f81da9f2ce27e73e9e95de716b444a88486600f4d
size 2625440

+ 2
- 2
Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c8e8d2f57e329f92cb93b55207f5503202561f255ea42a94928d442f2242f556
size 214523
oid sha256:c9f869597272fd86bfc59dfb1e3a8872795c1485a0ea1aa391eba0356ead9bbc
size 215101

+ 59
- 12
Assets/Scripts/Character.cs View File

@ -203,7 +203,7 @@ public class Character : MonoBehaviour
{
float elapsedTime = 0;
Vector3 startPosition = Current.transform.position;
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 1.0f);
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
@ -219,7 +219,7 @@ public class Character : MonoBehaviour
{
float elapsedTime = 0;
Vector3 startPosition = Current.transform.position;
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 1.0f);
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
@ -296,36 +296,83 @@ public class Character : MonoBehaviour
_currentBlock = moveTo;
StartCoroutine(MoveDownCoroutine(_currentBlock, transform, speed, 0.3f));
}
//set current block && move
//CurrentBlock = moveTo;
//StartCoroutine(MoveCoroutine(CurrentBlock, transform, speed, 0.3f));
//transform.position = CurrentBlock.VisualPosition;
}
public void conveyorMoveForward(Direction direction, float speed)
{
StartCoroutine(MoveConveyorForwardCoroutine(_currentBlock, transform, speed, 0.3f));
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorForwardCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void conveyorMoveBackward(Direction direction, float speed)
{
StartCoroutine(MoveConveyorBackwardCoroutine(_currentBlock, transform, speed, 0.3f));
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorBackwardCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void conveyorMoveLeft(Direction direction, float speed)
{
StartCoroutine(MoveConveyorLeftCoroutine(_currentBlock, transform, speed, 0.3f));
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorLeftCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void conveyorMoveRight(Direction direction, float speed)
{
StartCoroutine(MoveConveyorRightCoroutine(_currentBlock, transform, speed, 0.3f));
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorRightCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void CannonRMove(float speed)
{
StartCoroutine(PushRightCoroutine(transform, speed));
Direction direction = Direction.Right;
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(PushRightCoroutine(transform, speed));
}
}
public void CannonLMove(float speed)
{
StartCoroutine(PushLeftCoroutine(transform, speed));
Direction direction = Direction.Left;
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(PushLeftCoroutine(transform, speed));
}
}

+ 7
- 7
Assets/Scripts/Traps/CannonShot.cs View File

@ -16,17 +16,17 @@ public class CannonShot : MonoBehaviour
{
Names.Add("Character");
rb = this.gameObject.GetComponent<Rigidbody>();
for (int i = 0; i < clientData.AllClients.Count; i++)
/*for (int i = 0; i < clientData.AllClients.Count; i++)
{
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
}
}*/
}
IEnumerator PushLeftCoroutine(float time)
{
float elapsedTime = 0;
Vector3 startPosition = transform.position;
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.0f);
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
@ -38,11 +38,11 @@ public class CannonShot : MonoBehaviour
transform.position = endPosition;
Destroy(gameObject);
}
IEnumerator PushRightCoroutine(Transform Current, float time)
IEnumerator PushRightCoroutine(float time)
{
float elapsedTime = 0;
Vector3 startPosition = transform.position;
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.0f);
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
@ -66,8 +66,8 @@ public class CannonShot : MonoBehaviour
Rigidbody playerRB = player.GetComponent<Rigidbody>();
if (shootingRight == true)
{
StartCoroutine(PushLeftCoroutine(0.5f));
player.GetComponent<Character>().CannonLMove(0.5f);
StartCoroutine(PushRightCoroutine(0.5f));
player.GetComponent<Character>().CannonRMove(0.5f);
}
else
{

+ 14
- 11
Assets/Scripts/Traps/ConveyorBelt.cs View File

@ -9,12 +9,21 @@ public class ConveyorBelt : MonoBehaviour
public ClientList clientData;
bool characterOnBelt = false;
GameObject player;
string charname;
string charname = "Character";
public List<string> Names = new List<string>();
public bool left;
public bool forward;
public bool triggeranimate;
private void Start()
{
for (int i = 0; i < clientData.ConnectedClients.Count; i++)
{
Names.Add(clientData.ConnectedClients[i].characterAnimal + "(Clone)");
}
}
private void Update()
{
//for testing purposes
@ -25,13 +34,7 @@ public class ConveyorBelt : MonoBehaviour
}
}
private void Start()
{
for (int i = 0; i < clientData.ConnectedClients.Count; i++)
{
Names.Add(clientData.ConnectedClients[i].characterAnimal + "(Clone)");
}
}
void OnTriggerEnter(Collider other)
{
for (int i = 0; i < Names.Count; i++)
@ -54,15 +57,15 @@ public class ConveyorBelt : MonoBehaviour
}
else if (forward == false)
{
player.GetComponent<Character>().conveyorMoveBackward(Direction.Forward, 1.0f);
player.GetComponent<Character>().conveyorMoveBackward(Direction.Back, 1.0f);
}
else if (left == true)
{
player.GetComponent<Character>().conveyorMoveLeft(Direction.Forward, 1.0f);
player.GetComponent<Character>().conveyorMoveLeft(Direction.Left, 1.0f);
}
else if (left == false)
{
player.GetComponent<Character>().conveyorMoveRight(Direction.Forward, 1.0f);
player.GetComponent<Character>().conveyorMoveRight(Direction.Right, 1.0f);
}
}
}

+ 16
- 1
Assets/Scripts/Traps/CrushingBoulder.cs View File

@ -1,14 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class CrushingBoulder : MonoBehaviour
{
public bool triggeranimate;
public bool triggeranimate1;
public int countdowntimer;
public TextMeshPro counter;
int countdown;
private void Start()
{
countdown = countdowntimer;
}
private void Update()
{
counter.text = countdown.ToString();
//for testing purposes
if (triggeranimate == true)
{
@ -39,7 +48,13 @@ public class CrushingBoulder : MonoBehaviour
public void Animate()
{
StartCoroutine(FallRaiseCoroutine(-2.0f));
countdown--;
if (countdown == 0)
{
StartCoroutine(FallRaiseCoroutine(-2.0f));
countdown = countdowntimer;
returnToPosition();
}
}
public void returnToPosition()
{

+ 23
- 9
Assets/Scripts/Traps/ShootingCannon.cs View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
@ -9,9 +10,17 @@ public class ShootingCannon : MonoBehaviour
public bool triggeranimate;
public GameObject shootingObject;
public Transform spawnLocation;
public TextMeshPro counter;
public int countdowntimer;
int countdown;
private void Start()
{
countdown = countdowntimer;
}
private void Update()
{
counter.text = countdown.ToString();
//for testing purposes
if (triggeranimate == true)
{
@ -22,14 +31,19 @@ public class ShootingCannon : MonoBehaviour
public void Animate()
{
GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
if (shootingRight == true)
{
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
}
else
{
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
}
countdown--;
// if (countdown == 0){
GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
if (shootingRight == true)
{
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
}
else
{
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
}
countdown = countdowntimer;
//}
}
}

+ 50
- 19
Assets/Scripts/Traps/Traps.cs View File

@ -5,38 +5,69 @@ using UnityEngine;
public class Traps : MonoBehaviour
{
public List<ConveyorBelt> ConveyorBelts;
public List<CrushingBoulder> CrushingBoulders;
public List<CubeWithCrystals> CubesWithCrystals;
public List<FloatingOnWater> FloatingOnWater;
//public List<InGroundTrap> InGroundTraps;
public List<ShootingCannon> ShootingCannons;
public List<ConveyorBelt> ConveyorBelts = new List<ConveyorBelt>();
public List<CrushingBoulder> CrushingBoulders = new List<CrushingBoulder>();
public List<CubeWithCrystals> CubesWithCrystals = new List<CubeWithCrystals>();
public List<FloatingOnWater> FloatingOnWater = new List<FloatingOnWater>();
public List<InGroundTrap> InGroundTraps = new List<InGroundTrap>();
public List<ShootingCannon> ShootingCannons = new List<ShootingCannon>();
private void Start()
{
ConveyorBelts.AddRange(GameObject.FindObjectsOfType<ConveyorBelt>());
CrushingBoulders.AddRange(GameObject.FindObjectsOfType<CrushingBoulder>());
CubesWithCrystals.AddRange(GameObject.FindObjectsOfType<CubeWithCrystals>());
FloatingOnWater.AddRange(GameObject.FindObjectsOfType<FloatingOnWater>());
InGroundTraps.AddRange(GameObject.FindObjectsOfType<InGroundTrap>());
ShootingCannons.AddRange(GameObject.FindObjectsOfType<ShootingCannon>());
}
public void environmentTurn()
{
for(int a = 0; a < ConveyorBelts.Count; a++)
if (ConveyorBelts.Count > 0)
{
ConveyorBelts[a].GetComponent<ConveyorBelt>().Animate();
foreach(ConveyorBelt belt in ConveyorBelts)
{
belt.Animate();
}
}
for (int b = 0; b < CrushingBoulders.Count; b++)
if (CrushingBoulders.Count > 0)
{
CrushingBoulders[b].GetComponent<CrushingBoulder>().Animate();
foreach (CrushingBoulder boulder in CrushingBoulders)
{
boulder.Animate();
}
}
for (int c = 0; c < CubesWithCrystals.Count; c++)
if (ShootingCannons.Count > 0)
{
CubesWithCrystals[c].GetComponent<CubeWithCrystals>().Animate();
foreach (ShootingCannon cannon in ShootingCannons)
{
cannon.Animate();
}
}
for (int d = 0; d < FloatingOnWater.Count; d++)
}
public void environmentRound()
{
if (CubesWithCrystals.Count > 0)
{
FloatingOnWater[d].GetComponent<FloatingOnWater>().Animate();
foreach (CubeWithCrystals crystal in CubesWithCrystals)
{
crystal.Animate();
}
}
/*for (int e = 0; e < InGroundTraps.Count; e++)
if (FloatingOnWater.Count > 0)
{
InGroundTraps[e].GetComponent<InGroundTrap>().Animate();
}*/
for (int f = 0; f < ShootingCannons.Count; f++)
foreach (FloatingOnWater water in FloatingOnWater)
{
water.Animate();
}
}
if (InGroundTraps.Count > 0)
{
ShootingCannons[f].GetComponent<ShootingCannon>().Animate();
foreach (InGroundTrap ground in InGroundTraps)
{
ground.Animate();
}
}
}
}

Loading…
Cancel
Save