Пример #1
0
    void OnTriggerEnter2D(Collider2D p_other)
    {
        if (p_other.CompareTag("Hazard"))
        {
            Player.instance.Die();
        }

        if (p_other.CompareTag("Checkpoint"))
        {
            CheckpointManager.instance.GetCheckpoint(p_other.GetComponent <Checkpoint>());
        }

        if (p_other.CompareTag("Goal"))
        {
            ProgressManager.instance.HitGoal();
        }

        if (p_other.CompareTag("Advance"))
        {
            Player.instance.HitAdvance();
        }

        if (p_other.CompareTag("Ability"))
        {
            AbilityPickup          l_pickup  = p_other.GetComponent <AbilityPickup> ();
            AbilityManager.Ability l_ability = l_pickup.ability;
            string l_key = l_pickup.messageKey;
            Player.instance.PickupAbility(l_ability, l_key);
            p_other.gameObject.SetActive(false);
        }
    }
Пример #2
0
    private void OnTriggerEnter(Collider other)
    {
        AbilityPickup pickup = other.gameObject.GetComponentInChildren <AbilityPickup>();

        if (pickup != null)
        {
            switch (pickup.ability)
            {
            case AbilityPickup.Ability.Jump:
                allowJump = true;
                break;

            case AbilityPickup.Ability.Pickup:
                Debug.Log("Enable pickup");
                allowPickup = true;
                break;

            case AbilityPickup.Ability.WalkLeft:
                allowLeftMovement = true;
                break;

            case AbilityPickup.Ability.WalkRight:
                allowRightMovement = true;
                break;
            }
            Destroy(pickup.gameObject);
        }
        InsertZone insert = other.gameObject.GetComponent <InsertZone>();

        if (insert != null)
        {
            Debug.Log("Add insert " + insert.name);
            inserts.Add(insert.insert);
        }
    }
    // collects pickups automatically when they make contact with the player's main collider
    public void OnTriggerEnter(Collider other)
    {
        AbilityPickup pickup = other.gameObject.GetComponent <AbilityPickup>();

        if (pickup != null)
        {
            EquipAbility(pickup.HeldAbility);
            pickup.DeactivateObject();

            _cooldownTimer = 0;
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!collision.CompareTag("Ability"))
        {
            return;
        }

        AbilityPickup ap = collision.gameObject.GetComponent <AbilityPickup>();

        if (ap.MyAbility.name == "Hook")
        {
            OnHookPickup();
        }

        currentAbility = ap.MyAbility;

        Destroy(collision.gameObject);
    }