Example #1
0
    /// <summary>
    /// this is a custom update function, where I can tell it when/where to update
    /// </summary>
    /// <returns></returns>
    private IEnumerator GameLogic()
    {
        TankGameEvents.OnResetGameEvent?.Invoke(); // invoke our resetGameEvent
        TankGameEvents.OnPreGameEvent?.Invoke();   // call our pregame event
        TankGameEvents.SpawnTanksEvent(10);        // might want to do different things between tank spawed and game started
        yield return(new WaitForSeconds(preGameWaitTime));

        TankGameEvents.OnGameStartedEvent?.Invoke(); // start our game up

        // do something else in too

        yield return(null); // this tells our coroutine when the next "frame/update" should occur
    }
Example #2
0
 /// <summary>
 /// called upon another object entering any objects trigger attached with an instance of this script
 /// </summary>
 /// <param name="other"></param>
 private void OnTriggerEnter(Collider other)
 {
     if (triggered == false)                                                  //if the mine has not yet been triggered.
     {
         if (other.tag == "tank")                                             //checks to see if the object in the trigger zone is tagged as tank, if it is the run the below code
         {
             TriggerMine();                                                   //call the TriggerMine function.
             triggered = true;                                                // sets the status of weather the mine is triggered to true
             Debug.Log("Tank Has Entered the mine trigger zone");             //logs out the message when the tank has entered the trigger zone.
             other.GetComponent <Rigidbody>().AddForce(Vector3.up * 300);     //gets the rigid body of the other object and adds force on the 'Y' axis
             TankGameEvents.OnObjectTakeDamageEvent(other.transform, -20.0f); //calls the on take damage event and deals damage using the health function in nathans scripts.
         }
         // i have left Quicksand out on purpose in this statement to show that below code works.
         //checks to see if the object colliding with ther mines trigger zone has one of these tags
         else if (other.tag != "Quicksand" && other.tag != "HealingZone" && other.tag != "UnInteractable")
         {
             //if the object does not have one of the above tags then debug log the below
             Debug.LogWarning("something else is Activating this trigger" + " " + other.transform.name.ToString());
         }
     }
 }
Example #3
0
 private void ResetRound()
 {
     TankGameEvents.OnRoundResetEvent?.Invoke();
     TankGameEvents.SpawnTanksEvent(10); // might want to do different things between tank spawed and game started
     Invoke("BeginRound", 2);
 }