示例#1
0
            private void OnTriggerStay2D(Collider2D other)
            {
                if (canShoot)
                {
                    NormalCrabBehaviour ncb = other.GetComponent <NormalCrabBehaviour>();
                    CrabParrotBehavior  cpb = other.GetComponent <CrabParrotBehavior>();

                    if (ncb != null)
                    {
                        ncb.isShot = true;
                        FindObjectOfType <AudioManager>().Play("Coup de Golf");
                    }
                    else if (cpb != null)
                    {
                        cpb.isShot = true;
                        FindObjectOfType <AudioManager>().Play("Frappe Perroquet");
                        canShoot = false;
                        StartCoroutine(Lose());
                    }
                    IEnumerator Lose()
                    {
                        yield return(new WaitForSeconds(1));

                        animator.SetBool("Lose", true);
                        FindObjectOfType <AudioManager>().Play("Défaite");
                    }
                }
            }
示例#2
0
            private void OnTriggerEnter2D(Collider2D collision)
            {
                NormalCrabBehaviour ncb = collision.GetComponent <NormalCrabBehaviour>();
                CrabParrotBehavior  cpb = collision.GetComponent <CrabParrotBehavior>();

                if (cpb != null)
                {
                    markDontShot.enabled = true;
                }
                else if (ncb != null)
                {
                    markShot.enabled = true;
                }
            }
            private void OnTriggerStay2D(Collider2D other)
            {
                if (canShoot)
                {
                    NormalCrabBehaviour ncb = other.GetComponent <NormalCrabBehaviour>();
                    CrabParrotBehavior  cpb = other.GetComponent <CrabParrotBehavior>();

                    if (ncb != null)
                    {
                        ncb.isShot = true;
                    }
                    else if (cpb != null)
                    {
                        cpb.isShot = true;
                        canShoot   = false;
                        animator.SetBool("Lose", true);
                    }
                }
            }
            //TimedUpdate is called once every tick.
            public override void TimedUpdate()
            {
                int typeCrab;

                if (Tick == 2)
                {
                    if (CP < numberCP)
                    {
                        typeCrab = Random.Range(0, 2);
                    }
                    else
                    {
                        typeCrab = 1;
                    }

                    if (typeCrab == 1)
                    {
                        NormalCrabBehaviour currentCrab = Instantiate(crab, new Vector3(-8, -3, 0), Quaternion.identity).GetComponent <NormalCrabBehaviour>();
                    }
                    else if (typeCrab == 0)
                    {
                        Instantiate(crabParrot, new Vector3(-8, -3, 0), Quaternion.identity);
                        CP += 1;
                    }
                }
                if (Tick == 3)
                {
                    if (CP < numberCP)
                    {
                        typeCrab = Random.Range(0, 2);
                    }
                    else
                    {
                        typeCrab = 1;
                    }

                    if (typeCrab == 1)
                    {
                        Instantiate(crab, new Vector3(-8, -3, 0), Quaternion.identity);
                    }
                    else if (typeCrab == 0)
                    {
                        Instantiate(crabParrot, new Vector3(-8, -3, 0), Quaternion.identity);
                        CP += 1;
                    }
                }

                if (Tick == 4)
                {
                    if (CP < numberCP)
                    {
                        typeCrab = Random.Range(0, 2);
                    }
                    else
                    {
                        typeCrab = 1;
                    }

                    if (typeCrab == 1)
                    {
                        Instantiate(crab, new Vector3(-8, -3, 0), Quaternion.identity);
                    }
                    else if (typeCrab == 0)
                    {
                        Instantiate(crabParrot, new Vector3(-8, -3, 0), Quaternion.identity);
                        CP += 1;
                    }
                }

                if (Tick == 5)
                {
                    if (CP < numberCP)
                    {
                        typeCrab = Random.Range(0, 2);
                    }
                    else
                    {
                        typeCrab = 1;
                    }

                    if (typeCrab == 1)
                    {
                        Instantiate(crab, new Vector3(-8, -3, 0), Quaternion.identity);
                    }
                    else if (typeCrab == 0)
                    {
                        Instantiate(crabParrot, new Vector3(-8, -3, 0), Quaternion.identity);
                        CP += 1;
                    }
                }
                if (Tick == 8 && !lose)
                {
                    Manager.Instance.Result(true);
                }
                else if (Tick == 8 && lose)
                {
                    Manager.Instance.Result(false);
                }
            }