Ejemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject o = collision.gameObject;

        //Debug.Log(233);
        if (this.status == WeaselStatus.prepare || this.status == WeaselStatus.lose)
        {
            if (this.status == WeaselStatus.prepare)
            {
                switch (this.direction)
                {
                case Direction.buttom:
                case Direction.top:
                    this.SetSpeed(new Vector2(this.mySpeed.x, -this.mySpeed.y));
                    break;

                case Direction.right:
                case Direction.left:
                    this.SetSpeed(new Vector2(-this.mySpeed.x, this.mySpeed.y));
                    break;
                }
            }
            if (o.tag == "chick")
            {
                this.status = WeaselStatus.get;
                getChick    = o;

                /*o.transform.parent = this.gameObject.transform;
                 * o.transform.localScale = new Vector3(1, 1, 1);
                 * o.transform.localPosition = new Vector3(
                 *  this.mySpeed.x / Mathf.Abs(this.mySpeed.x) * 1.0f,
                 *  0.4f,
                 *  0
                 * );*/
                o.SendMessage("Catched", this);
            }
        }
        if (o.tag == "mom")
        {
            this.status   = WeaselStatus.lose;
            this.getChick = null;
            AudioControl.PlayMusic(bark);
        }
    }
Ejemplo n.º 2
0
    private void OnEnable()
    {
        AudioControl.PlayMusic(bark);
        int r = Random.Range(0, 2);

        if (r == 0)
        {
            this.transform.position = new Vector3(Random.Range(-width, width), height * Mathf.Pow(-1, Random.Range(0, 2)));
        }
        else
        {
            this.transform.position = new Vector3(width * Mathf.Pow(-1, Random.Range(0, 2)), Random.Range(-height, height));
        }
        mySpeed = Vector2.zero;
        IntroTarget();
        SetSpeed();
        //this.Invoke("SetSpeed", 5);
        Debug.Log(this.status.ToString());
        this.status = WeaselStatus.prepare;
        int temp = mom.chickList.Count;
        int n    = Random.Range(0, temp);
        //Debug.Log("55555");
    }