Browse Source

Cannon fixed and tested - need to limit the pushing of the character!

Josh_Dev_branch
ClairePeta 4 years ago
parent
commit
170c11a7e3
9 changed files with 131 additions and 42 deletions
  1. +47
    -0
      Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab
  2. +1
    -0
      Assets/Prefabs/Traps/Conveyor Belt.prefab
  3. +5
    -4
      Assets/Prefabs/Traps/ShootingCannon.prefab
  4. +2
    -2
      Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity
  5. +2
    -2
      Assets/Scenes/Trap Creation - Claire.unity
  6. +6
    -6
      Assets/Scripts/Character.cs
  7. +45
    -0
      Assets/Scripts/Traps/CannonShot.cs
  8. +11
    -0
      Assets/Scripts/Traps/CannonShot.cs.meta
  9. +12
    -28
      Assets/Scripts/Traps/ShootingCannon.cs

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

@ -9,6 +9,9 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4787400513692267026}
- component: {fileID: 535408673737125727}
- component: {fileID: 3386372059152676518}
- component: {fileID: 3493367438702709850}
m_Layer: 0
m_Name: Cannon_Shooting_Object
m_TagString: Untagged
@ -31,6 +34,50 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &535408673737125727
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3506936643819969965}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 20a19dbbf99278d49837cc757add262e, type: 3}
m_Name:
m_EditorClassIdentifier:
shootingRight: 0
clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2}
Names: []
--- !u!54 &3386372059152676518
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3506936643819969965}
serializedVersion: 2
m_Mass: 1
m_Drag: 1
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!65 &3493367438702709850
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3506936643819969965}
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!1001 &4032901744580679509
PrefabInstance:
m_ObjectHideFlags: 0

+ 1
- 0
Assets/Prefabs/Traps/Conveyor Belt.prefab View File

@ -44,6 +44,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6692f0c965cb4fa41b616ba0991653a3, type: 3}
m_Name:
m_EditorClassIdentifier:
clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2}
--- !u!1 &6298733943245737397
GameObject:
m_ObjectHideFlags: 0

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

@ -189,11 +189,11 @@ MonoBehaviour:
lineCount: 1
pageCount: 1
materialCount: 1
m_havePropertiesChanged: 0
m_havePropertiesChanged: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_isInputParsingRequired: 0
m_isInputParsingRequired: 1
m_inputSource: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 1907555566}
@ -254,8 +254,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
shootingRight: 0
shootingObject: {fileID: 0}
clientData: {fileID: 0}
shootingObject: {fileID: 3506936643819969965, guid: e8cf547bc36bd094f860f652fbe08047,
type: 3}
clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2}
--- !u!65 &7713460145294617833
BoxCollider:
m_ObjectHideFlags: 0

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

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9b3eb5b014234b0d7d70f386fca2cb0bad8d1c78c801f973239658d26b6f8529
size 176471
oid sha256:57a10796a4b6ae47785d5aff82e05827e60c3c87a05107f924f289f3bd48265b
size 175456

+ 2
- 2
Assets/Scenes/Trap Creation - Claire.unity View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:153aef7b45a8aadfaedd2163e8244b73d7ba415080bd40510823bcecd1d69fae
size 24764
oid sha256:80df00e537192d540e13c331dab9d71395b5c35ff337d240795774117fb0478f
size 23536

+ 6
- 6
Assets/Scripts/Character.cs View File

@ -148,8 +148,8 @@ public class Character : MonoBehaviour
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);
Vector3 startPosition = Current.transform.position;
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 10);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
@ -164,8 +164,8 @@ public class Character : MonoBehaviour
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);
Vector3 startPosition = Current.transform.position;
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 10);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
@ -253,11 +253,11 @@ public class Character : MonoBehaviour
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
StartCoroutine(MoveConveyorCoroutine(_currentBlock, transform, speed, 0.3f));
}
public void CannonRMove(Direction direction, float speed)
public void CannonRMove(float speed)
{
StartCoroutine(PushRightCoroutine(transform, speed));
}
public void CannonLMove(Direction direction, float speed)
public void CannonLMove(float speed)
{
StartCoroutine(PushLeftCoroutine(transform, speed));
}

+ 45
- 0
Assets/Scripts/Traps/CannonShot.cs View File

@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
public class CannonShot : MonoBehaviour
{
public bool shootingRight;
public ConnectedClients clientData;
GameObject player;
string charname;
public List<string> Names;
private void Start()
{
Names.Add("Character");
/*for (int i = 0; i < clientData.AllClients.Count; i++)
{
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
}*/
}
void OnTriggerEnter(Collider other)
{
foreach (string name in Names)
{
Debug.Log(name);
if (other.gameObject.name == name)
{
charname = other.gameObject.name;
Debug.Log(charname);
player = GameObject.Find(charname);
if (shootingRight == true)
{
player.GetComponent<Character>().CannonLMove(1.0f);
}
else
{
player.GetComponent<Character>().CannonLMove(1.0f);
}
}
}
}
}

+ 11
- 0
Assets/Scripts/Traps/CannonShot.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20a19dbbf99278d49837cc757add262e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 12
- 28
Assets/Scripts/Traps/ShootingCannon.cs View File

@ -1,51 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
public class ShootingCannon : MonoBehaviour
{
public bool shootingRight;
public bool triggeranimate;
public GameObject shootingObject;
public ConnectedClients clientData;
bool characterOnBelt = false;
GameObject player;
string charname;
private List<string> Names;
public Transform spawnLocation;
private void Start()
private void Update()
{
for (int i = 0; i < clientData.AllClients.Count; i++)
//for testing purposes
if (triggeranimate == true)
{
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;
}
Animate();
triggeranimate = false;
}
}
public void Animate()
{
Vector3 position = new Vector3(0.0f, 1.338f, 0.25f);
GameObject shot = Instantiate(shootingObject, position, Quaternion.identity);
player = GameObject.Find(charname);
if(shootingRight == true)
GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
if (shootingRight == true)
{
player.GetComponent<Character>().CannonRMove(Direction.Forward, 1.0f);
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
}
else
{
player.GetComponent<Character>().CannonLMove(Direction.Forward, 1.0f);
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
}
}
}

Loading…
Cancel
Save