示例#1
0
 //If inside of trigger
 private void OnTriggerStay(Collider other)
 {
     //Attempt ot join battle if trigger is BattleArea
     if (other.tag == "BattleArea" && !inBattle)
     {
         BattleArea area = other.GetComponent <BattleArea>();
         if (area.AreOpenSpots())
         {
             currentBattleArea = area;
             currentBattleArea.AddCreature(gameObject, true);
             inBattle = true;
         }
         else
         {
             Destroy(this.gameObject);
         }
     }
 }
示例#2
0
 //When enemy hits another trigger
 private void OnTriggerEnter(Collider other)
 {
     //If trigger is for BattleArea, attempt to join battle
     if (other.tag == "BattleArea" && !inBattle)
     {
         BattleArea area = other.GetComponent <BattleArea>();
         if (area.AreOpenSpots())
         {
             currentBattleArea = area;
             currentBattleArea.AddCreature(gameObject, true);
             inBattle = true;
         }
         else
         {
             Destroy(this.gameObject);
         }
     }
     //If trigger is part of path, keep following path
     else if (other.tag == "PathBlock")
     {
         currentPathTarget  = GetNextSpot(other.gameObject);
         transform.rotation = currentPathTarget.transform.rotation;
     }
 }