Beispiel #1
0
    // Start is called before the first frame update

    void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <Reactive_target_player>())
        {
            Reactive_target_player RTP = other.GetComponent <Reactive_target_player>();
            switch (NumberItem)
            {
            case 1:
                Debug.Log("Heal Bonus");
                RTP.Heal();
                break;

            case 2:
                Debug.Log("Add Life Bonus");
                RTP.AddLife();
                break;

            case 3:
                Debug.Log("Merge Bonus");
                break;

            case 4:
                Debug.Log("WhitePower Bonus");
                break;
            }
            Destroy(this.gameObject);
        }
    }
Beispiel #2
0
    IEnumerator Attack()
    {
        while (true)
        {
            /*test the minimum distance to attack */
            if (Vector3.Distance(Player.position, transform.position) < 1.5)
            {
                transform.LookAt(Player.position);
                /*start animation attack*/
                _animator.SetBool("close", true);
                /*start sound attack*/
                whoosh.Play();
                yield return(new WaitForSeconds(1f));

                /*wait 1 second and test if the distance is enough close for touch
                 * after 1 seconds the candy is in the middle of animation. */
                if (Vector3.Distance(Player.position, transform.position) < 1)
                {
                    Reactive_target_player RTP = Player.GetComponent <Reactive_target_player>();
                    RTP.ReactoHit();
                }

                yield return(new WaitForSeconds(1f));

                /*the animation attack is finished*/
                _animator.SetBool("close", false);
            }
            /*wait 0.5 second for the next attack*/
            yield return(new WaitForSeconds(0.5f));
        }
    }
Beispiel #3
0
    private void OnTriggerEnter(Collider other)
    {
        Reactive_target_player player = other.GetComponent <Reactive_target_player>();

        if (player != null)
        {
            player.ReactoHit();
        }
        Destroy(this.gameObject);
    }