예제 #1
0
 /// <summary>
 /// Activates the affected objects connected and plays animation on the interacting player.
 /// </summary>
 /// <param name="player"></param>
 public override void Interact(GameObject player)
 {
     if (interacting == false && actionDelay <= 0)
     {
         if (affectedObjectList.Length == 0)
         {
             affectedObject.ExecuteAction();
         }
         else
         {
             foreach (AffectedObject obj in affectedObjectList)
             {
                 obj.ExecuteAction();
             }
         }
         interacting = true;
         StartCoroutine(InteractionCooldown());
         if (button != null)
         {
             StartCoroutine(ButtonMovement());
         }
         if (onTimer == true)
         {
             StartCoroutine(OnATimer());
         }
         foreach (Interactable otherSwitch in connectedSwitches)
         {
             if (otherSwitch.interacting == false)
             {
                 otherSwitch.StartInteraction();
             }
         }
         player.GetComponent <NewPlayerScript>().Freeze(animationDuration);
         player.GetComponent <NewPlayerScript>().StartAnimation("Push Button");
     }
     else if (interacting == false && actionDelay > 0)
     {
         player.GetComponent <NewPlayerScript>().Freeze(animationDuration);
         player.GetComponent <NewPlayerScript>().StartAnimation("Push Button");
         StartCoroutine(ActionDelay());
     }
 }