Added Main menu Changes to UI
Added Rules Menu Changes to UI Added Cutscenes to the rules scene Reorganised Files
This commit is contained in:
68
Assets/Scripts/Other Scripts/laserCollider.cs
Normal file
68
Assets/Scripts/Other Scripts/laserCollider.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
/// <summary>
|
||||
/// Class to deal with the other collisions for the core
|
||||
/// </summary>
|
||||
public class laserCollider : ColliderManager
|
||||
{
|
||||
public AudioClip corePickupSFX;
|
||||
public GameObject laserToken;
|
||||
public int laserTick;
|
||||
public GameObject LaserStick1;
|
||||
public GameObject LaserStick2;
|
||||
|
||||
// Bool checks if the core has been collected, this is because the ships are made of multiple collision boxes and would trigger more than once.
|
||||
private bool _tokenCollected = false;
|
||||
|
||||
public override void ProcessCollision(CollisionDirection direction, Collision collision, bool wasChild)
|
||||
{
|
||||
GameObject collisionGO;
|
||||
if (wasChild)
|
||||
{
|
||||
collisionGO = collision.transform.parent.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
collisionGO = collision.gameObject;
|
||||
}
|
||||
|
||||
// Check the tag of the collided object, Direction doesnt matter i assume
|
||||
switch (collisionGO.tag)
|
||||
{
|
||||
case "Player":
|
||||
PickupToken();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the core pick up and destroy the core object.
|
||||
/// </summary>
|
||||
public void PickupToken()
|
||||
{
|
||||
// If the core has been collected ignore it.
|
||||
if (!_tokenCollected)
|
||||
{
|
||||
Debug.Log("Pick up laser");
|
||||
_tokenCollected = true;
|
||||
AudioSource.PlayClipAtPoint(corePickupSFX, transform.position);
|
||||
Destroy(laserToken);
|
||||
while (laserTick != 0)
|
||||
{
|
||||
LaserStick1.transform.localScale = new Vector3(0.07000001f, 1.2f, 0.07000001f);
|
||||
LaserStick1.transform.position = new Vector3(LaserStick1.transform.position.x - 5.27541f,
|
||||
LaserStick1.transform.position.y - 1.240699f, LaserStick1.transform.position.z + 3.87f);
|
||||
|
||||
LaserStick2.transform.localScale = new Vector3(0.07000001f, 1.2f, 0.07000001f);
|
||||
LaserStick2.transform.position = new Vector3(LaserStick2.transform.position.x - 0.2f,
|
||||
LaserStick2.transform.position.y - 1.3f, LaserStick2.transform.position.z + 3.62f);
|
||||
laserTick -= 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user