Ejemplo n.º 1
0
    public void OnGetHit(Ram ram)
    {
        if (this._invincible)
        {
            return;
        }

        ram.GetComponent <Sheep>().GetFrightened(4);
        ram.GetComponent <WanderSheep>().ClearBehaviour();

        this._health    -= 25;
        this._invincible = true;

        AudioManager.instance.StopSound("Bark");
        AudioManager.instance.PlaySound("Whine");
        AudioManager.instance.PlaySound("Bonk");

        this._animal.moveUp    = false;
        this._animal.moveDown  = false;
        this._animal.moveLeft  = false;
        this._animal.moveRight = false;

        this._animal.controlsActive = false;
        this._jumpToggle            = false;
        this._barkAction            = false;


        this.barkTransform.gameObject.SetActive(false);
        this.wolfSprite.transform.localPosition = new Vector3(0, .15f, 0);

        //Start blinking
        CancelInvoke("Bark");
        CancelInvoke("EndBlinking");
        CancelInvoke("EnableControls");
        Invoke("EnableControls", 2f);
        Invoke("EndBlinking", 4f);
        InvokeRepeating("Blink", .15f, .15f);
    }
Ejemplo n.º 2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (!this._eating && !this._barkAction && GameManager.instance.gameActive)
        {
            this._eating      = true;
            this._eatingTimer = 1.5f;

            this.wolfSprite.sprite = this.mouthFullSprite;

            if (collision.gameObject.tag == "Edible")
            {
                AudioManager.instance.PlaySound("Eat");

                Ram ram = collision.gameObject.GetComponent <Ram>();
                if (ram && ram.GetComponent <Sheep>().aggression > 3f)
                {
                    OnGetHit(ram);
                }
                else
                {
                    SheepManager.instance.OnEat(collision.gameObject);
                }
            }
            else if (collision.gameObject.tag == "Inedible")
            {
                print("Don't eat the lamb");
                SheepManager.instance.OnEat(collision.gameObject);
            }
        }
        else
        {
            if (this._eating)
            {
                Ram ram = collision.gameObject.GetComponent <Ram>();

                if (ram && GameManager.instance.gameActive)
                {
                    OnGetHit(ram);
                }
            }
        }
    }