private void ActivateWaggleDance()
        {
            if (waggleCollected <= 0)
            {
                return;
            }

            bool didDance = false;

            if (curTarget != null)
            {
                if (curTarget.CompareTag("Enemy"))
                {
                    // This currently just feels like a different version of the free sting...
                    Debug.Log("here: " + curTarget.name);
                    FindObjectOfType <StingBehavior>().FinishSting(1, 1, curTarget);
                    didDance = true;
                }
                else if (curTarget.CompareTag("Collectible"))
                {
                    CollectibleBehavior cb = curTarget.GetComponent <CollectibleBehavior>();
                    if (cb == null)
                    {
                        return;
                    }

                    if (cb.collectibleType == CollectibleType.Pollen)
                    {
                        cb.SendMessage("ControllerCollisionListener", new object[] { GetComponent <PlayerControl>(), 2 });
                        didDance = true;
                    }
                }
                else if (curTarget.CompareTag("Hive"))
                {
                    HiveManager hm = FindObjectOfType <HiveManager>();
                    hm.ActivateHiveDefence();
                    didDance = true;
                }
            }
            else
            {
                // Our third dance, Shock, isn't needed till level 3. I'm thinking this is some sort of AoE attack?
                // However, I don't know what the best way to trigger it would be, and if this `else` case is enough.

                // temp
                didDance = false;
            }

            if (didDance)
            {
                Instantiate(swarmVfx, curTarget.transform.position, Quaternion.identity);
                AudioSource.PlayClipAtPoint(danceMusic, transform.position, 1f);
                curPowerup     = PlayerPowerup.WaggleDance;
                powerupTimeout = waggleDanceDuration;
                waggleCollected--;
                gui.UpdateGUI(PlayerPowerup.WaggleDance, waggleCollected);
            }
        }
Exemplo n.º 2
0
 // Instead of OnCollisionEnter, this is the method that is called
 // when the CharacterController enters a collision. The event is triggered on the
 // CharacterController object only. However, the action to take place
 // is supposed ot be done by CollectibleBehavior. So we are sending a message
 // to the CollectibleBehavior to do the task
 private void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.gameObject.CompareTag("Collectible"))
     {
         CollectibleBehavior cb = hit.gameObject.GetComponent <CollectibleBehavior>();
         if (cb == null)
         {
             return;
         }
         cb.SendMessage("ControllerCollisionListener", new object[] { player });
     }
     else if (hit.gameObject.CompareTag("Pesticide"))
     {
         PesticideBehavior pb = hit.gameObject.GetComponent <PesticideBehavior>();
         if (pb == null)
         {
             return;
         }
         pb.SendMessage("ControllerCollisionListener", new object[] { player });
     }
 }