Exemplo n.º 1
0
 public void OnSelectButton(int index)
 {
     for (int i = 0; i < this.toggleButtons.Count; i++)
     {
         ToggleButton tb = (ToggleButton)this.toggleButtons[i];
         if (index == i)
         {
             tb.Activate();
         }
         else
         {
             tb.Deactivate();
         }
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == GameTags.Player.ToString() && FollowTarget == null)
        {
            switch (MyType)
            {
            case CollectibleType.GENERICKEY:
            case CollectibleType.SPECIALKEY:
                //This is commanding the Collectible To start its pickup animation and put itself relative to the parent... Subject to change
                #region Old

                /*
                 * if (GetComponent<AnimController>() != null)
                 * {
                 *  transform.parent.parent = collision.transform;
                 *  transform.parent.localPosition = new Vector2(0, 0.5f);
                 *  GetComponent<AnimController>().ForceTrigger(AnimTriggers.EXMovement);
                 * }
                 * //Then since you're a key, Toggle the Portal to turn on.
                 * if (Portal != null)Portal.ToggleOn();
                 * else { Debug.LogWarning("This Key does not have a portal to target"); }
                 * //Destruction is handled with the end of the animation.
                 * //Destroy(this.gameObject);
                 */
                #endregion

                //So if the player collides with
                #region Tell the item what it's supposed to be following
                //FollowTarget = collision.gameObject;
                //collision.GetComponent<FollowManager>().AddObject(this.gameObject);
                //followDistance = collision.GetComponent<FollowManager>().GetFollowDistance(this.gameObject);
                FollMan = collision.GetComponent <FollowManager>();
                FollMan.AddObject(this.gameObject);
                #endregion
                break;

            case CollectibleType.TEMPSHOT:
                AbilitySlot = Mathf.Clamp(AbilitySlot, 0, 2);
                AuxNumber   = Mathf.Clamp(AuxNumber, 0, 200);
                collision.GetComponent <ActionInput>().SetTempAbility(AbilitySlot, MyAbility, AuxNumber);
                break;

            case CollectibleType.SHOTOVERRIDE:
                AbilitySlot = Mathf.Clamp(AbilitySlot, 0, 2);
                AuxNumber   = Mathf.Clamp(AuxNumber, 0, 200);
                collision.GetComponent <ActionInput>().OverrideBaseShot(AbilitySlot, MyAbility, AuxNumber);
                break;

            case CollectibleType.POWERUP:
                break;

            case CollectibleType.COLLECTIBLE:
                //So if it's a collectible it needs to talk to the Game Manager and tell it to update the current stage.
                break;

            default:
                Debug.Log("What the heck?");
                break;
            }
        }

        else if (FoundLock && collision.GetComponent <ToggleButton>())
        {
            ToggleButton Butt = FollowTarget.GetComponent <ToggleButton>();
            if (Butt.GetButtonType() == ButtonType.GenericLocked &&
                MyType == CollectibleType.GENERICKEY)
            {
                Debug.Log("I've found a generic Lock");
                Butt.Activate();
                this.gameObject.SetActive(false);
                FollMan.RemoveObject(this.gameObject);
            }
            else if (Butt.GetButtonType() == ButtonType.SpecialLocked &&
                     MyType == CollectibleType.SPECIALKEY &&
                     TargetToToggle.gameObject == Butt.gameObject)
            {
                Debug.Log("I've found a Special Lock");
                Butt.Activate();
                this.gameObject.SetActive(false);
                FollMan.RemoveObject(this.gameObject);
                //Debug.Log("I've Found the specialized Lock");
            }
        }
    }