示例#1
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        // hit walls
        if (!other.isTrigger && other.tag != "Player")
        {
            if (verbose)
            {
                Debug.Log("hit walls");
            }
            Destroy(gameObject);
            return;
        }

        var destructable = other.transform.GetComponent <Destructable>();

        if (destructable == null)
        {
            destructable = other.transform.GetComponentInParent <Destructable>();
        }
        if (destructable == null)
        {
            if (verbose)
            {
                Debug.Log(other.name + " is not destructable");
            }
            return;
        }

        if (other.tag == "Player")
        {
            BasicBehaviour player = GameManager.Instance.LocalPlayer;
            PlayerSkill    pk     = player.GetComponent <PlayerSkill>();
            if (pk.skill1working)
            {
                if (verbose)
                {
                    Debug.Log("Player are intangible now!");
                }
                return;
            }
        }

        destructable.TakeDamege(damage);
        Destroy(gameObject);
    }
    protected virtual void OnTriggerEnter(Collider other)
    {
        // hit walls
        if (!other.isTrigger && other.tag != "Player")
        {
            Debug.Log("hit walls");
            Destroy(gameObject);
            return;
        }

        var destructable = other.transform.GetComponent <Destructable>();

        if (destructable == null)
        {
            destructable = other.transform.GetComponentInParent <Destructable>();
        }
        if (destructable == null)
        {
            Debug.Log(other.name + " is not destructable");
            return;
        }

        if (other.tag == "Player")
        {
            BasicBehaviour player = GameManager.Instance.LocalPlayer;
            PlayerHealth   ph     = player.GetComponent <PlayerHealth>();
            if (ph.Intangible)
            {
                Debug.Log("hide " + ph.Intangible);
                return;
            }
        }

        destructable.TakeDamege(damage);
        Destroy(gameObject);
    }