Exemplo n.º 1
0
    void launchCarrot()
    {
        if (this.health > 0)
        {
            Vector3 my_pos    = this.transform.position;
            Vector3 rabit_pos = HeroRabbit.lastRabit.transform.position;

            if (Mathf.Abs(my_pos.x - rabit_pos.x) <= 7.0f)
            {
                if (Time.time - this.last_carrot > 4.0f && !HeroRabbit.lastRabit.isDead())
                {
                    this.last_carrot = Time.time;

                    GameObject obj = GameObject.Instantiate(this.carrot);
                    obj.transform.position = my_pos + Vector3.up * 0.5f;

                    Carrot carrot = obj.GetComponent <Carrot>();
                    if (rabit_pos.x < my_pos.x)
                    {
                        carrot.launch(-1);
                    }
                    else
                    {
                        carrot.launch(1);
                    }
                }
            }
        }
        if (SoundManager.Instance.isSoundOn())
        {
            attackSource.Play();
        }
    }
Exemplo n.º 2
0
    IEnumerator launchCarrot()
    {
        Vector3 my_pos    = this.transform.position;
        Vector3 rabit_pos = HeroRabit.lastRabit.transform.position;

        if (Mathf.Abs(rabit_pos.x - my_pos.x) < radius)
        {
            if (Time.time - this.lastCarrot > time)
            {
                this.lastCarrot = Time.time;
                if (sound)
                {
                    attackSource.Play();
                }
                animator.SetTrigger("attackRabit");

                yield return(new WaitForSeconds(0.2f));

                GameObject obj = GameObject.Instantiate(this.carrot);
                obj.transform.position = my_pos + Vector3.up * 0.5f;
                //Запускаємо в рух


                Carrot carrot = obj.GetComponent <Carrot> ();
                if (rabit_pos.x < my_pos.x)
                {
                    carrot.launch(-1);
                }
                else
                {
                    carrot.launch(1);
                }
            }
        }
    }
Exemplo n.º 3
0
    void launchCarrot()
    {
        Animator animator  = GetComponent <Animator> ();
        Vector3  my_pos    = this.transform.position;
        Vector3  rabit_pos = HeroRabit.lastRabit.transform.position;

        if (Time.time - this.lastCarrot > time)
        {
            if (SoundManager.Instance.isSoundOn())
            {
                attackSource.Play();
            }
            animator.SetTrigger("attack");
            this.lastCarrot = Time.time;
            GameObject gameObject = GameObject.Instantiate(this.carrot);
            gameObject.transform.position = my_pos + Vector3.up * 0.5f;
            Carrot carrot = gameObject.GetComponent <Carrot> ();
            if (rabit_pos.x < my_pos.x)
            {
                carrot.launch(-1);
            }
            else
            {
                carrot.launch(1);
            }
        }
    }
Exemplo n.º 4
0
    IEnumerator attackLater()
    {
        yield return(new WaitForSeconds(0.1f));

        Vector3 rabbit_pos = HeroRabbit.current.transform.position;
        Vector3 orc_pos    = this.transform.position;

        if (SoundManager.manager.isSoundOn())
        {
            soundSource.Play();
        }
        this.orcAnimator.SetTrigger("attack");
        GameObject carrot = GameObject.Instantiate(weapon);

        carrot.transform.position = this.transform.position + Vector3.up * 0.5f;
        Carrot obj = carrot.GetComponent <Carrot> ();

        if (orc_pos.x < rabbit_pos.x)
        {
            obj.launch(1);
        }
        else if (orc_pos.x > rabbit_pos.x)
        {
            obj.launch(-1);
        }
    }
Exemplo n.º 5
0
    void launchCarrot(float direction)
    {
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        obj.transform.position = this.transform.position + (new Vector3(0f, 1f, 0f));
        Carrot carrot = obj.GetComponent <Carrot> ();

        carrot.launch(direction);
    }
Exemplo n.º 6
0
    void LaunchCarrot(float direction)
    {
        animator.SetTrigger("attack");
        last_carrot = Time.time;
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        obj.transform.position = this.transform.position + new Vector3(0, 1, 0);;
        Carrot carrot = obj.GetComponent <Carrot> ();

        carrot.launch(direction);
    }
Exemplo n.º 7
0
    void lauchCarrot()
    {
        if (!this.isDead)
        {
            Vector3 my_pos    = this.transform.position;
            Vector3 rabit_pos = HeroRabbit.lastRabit.transform.position;
            if (Mathf.Abs(my_pos.x - rabit_pos.x) <= 8.0f)
            {
                if (rabit_pos.x < my_pos.x)
                {
                    this.mode = Mode.CarrotLeft;
                }
                else
                {
                    this.mode = Mode.CarrotRight;
                }

                if (Time.time - this.last_carrot > 4.0f)
                {
                    this.last_carrot = Time.time;
                    GameObject obj = GameObject.Instantiate(this.carrot);
                    obj.transform.position = my_pos + Vector3.up * 2f;
                    Carrot carrot = obj.GetComponent <Carrot>();
                    this.GetComponent <Animator>().SetTrigger("attack");
                    if (rabit_pos.x < my_pos.x)
                    {
                        carrot.launch(-1);
                    }
                    else
                    {
                        carrot.launch(1);
                    }
                }
            }
            return;
        }
        if (this.mode == Mode.CarrotLeft || this.mode == Mode.CarrotRight)
        {
            this.mode = Mode.GoToA;
        }
    }
Exemplo n.º 8
0
    void launchCarrot(float direction)
    {
        //Створюємо копію Prefab
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        //Розміщуємо в просторі
        obj.transform.position = this.transform.position + new Vector3(0, this.GetComponent <BoxCollider2D>().size.y / 2 - 0.2f, 0);
        //Запускаємо в рух
        Carrot carrot = obj.GetComponent <Carrot>();

        carrot.launch(direction);
    }
Exemplo n.º 9
0
    void launchCarrot(float direction)
    {
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);
        Vector3    pos = this.transform.position;

        pos.y += this.GetComponent <SpriteRenderer> ().bounds.size.y / 2;
        obj.transform.position = pos;
        Carrot carrot = obj.GetComponent <Carrot> ();

        carrot.launch(direction);
        last_carrot = Time.time;
    }
Exemplo n.º 10
0
    void launchCarrot(Vector3 direction)
    {
        if (Time.time - lastCarrot > interval)
        {
            lastCarrot = Time.time;
            GameObject obj = GameObject.Instantiate(this.prefabCarrot);
            obj.transform.position = this.transform.position;

            Carrot carrot = obj.GetComponent <Carrot>();
            carrot.launch(direction);
        }
    }
Exemplo n.º 11
0
    void launchCarrot(float direction)
    {
        //Створюємо копію Prefab
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        //Розміщуємо в просторі
        obj.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 1, 0);
        //Запускаємо в рух
        Carrot carrot = obj.GetComponent <Carrot>();

        carrot.launch(direction);
    }
Exemplo n.º 12
0
    void launchCarrot(float direction)
    {
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        Vector3 my_pos = this.transform.position;

        my_pos.y = this.GetComponent <BoxCollider2D>().bounds.center.y;

        Carrot carrot = obj.GetComponent <Carrot>();

        carrot.transform.position = my_pos;
        carrot.launch(direction);
    }
Exemplo n.º 13
0
    IEnumerator attackPerform()
    {
        yield return(new WaitForSeconds(0.1f));

        Vector3 rabbit_pos = HeroRabbitGood.current.transform.position;
        Vector3 orc_pos    = this.transform.position;

        this.AnimController.SetTrigger("attack");
        GameObject ob = GameObject.Instantiate(this.carrprefab);

        ob.transform.position = this.transform.position + Vector3.up * 0.5f;
        Carrot goodcarrot = ob.GetComponent <Carrot>();

        if (orc_pos.x < rabbit_pos.x)
        {
            goodcarrot.launch(1);
        }
        else if (orc_pos.x > rabbit_pos.x)
        {
            goodcarrot.launch(-1);
        }
    }
Exemplo n.º 14
0
 void launchCarrot(float direction)
 {
     if (direction != 0)
     {
         GameObject obj = GameObject.Instantiate(this.prefabCarrot);
         //Розміщуємо в просторі
         obj.transform.position  = this.transform.position;
         obj.transform.position += new Vector3(0.0f, 1.0f, 0.0f);
         //Запускаємо в рух
         Carrot carrot = obj.GetComponent <Carrot>();
         carrot.launch(direction);
     }
 }
Exemplo n.º 15
0
    void throwCarrot(float direction)
    {
        GameObject obj       = GameObject.Instantiate(this.prefabCarrot);
        Vector3    orkSize   = this.GetComponent <Collider2D>().bounds.size;
        Transform  carrotPos = this.transform;
        float      x         = carrotPos.position.x + 0.5f;
        float      y         = carrotPos.position.y + orkSize.y / 2;

        obj.transform.position = new Vector3(x, y, 0.0f);
        Carrot carrot = obj.GetComponent <Carrot>();

        carrot.launch(direction);
    }
Exemplo n.º 16
0
    void launchCarrot(float direction)
    {
        Animator animator = GetComponent <Animator>();

        animator.SetTrigger("attack");

        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        obj.transform.position = this.transform.position + new Vector3(0, 0.7f, 0);

        Carrot carrot = obj.GetComponent <Carrot>();

        carrot.launch(direction);
    }
Exemplo n.º 17
0
 void launchCarrot(float direction)
 {
     if (direction != 0)
     {
         GameObject obj = GameObject.Instantiate(this.carrot);
         obj.transform.position = this.transform.position;
         Vector3 v  = new Vector3(0, 1, 0);
         Vector3 vf = obj.transform.position + v;
         obj.transform.position = vf;
         Carrot car = obj.GetComponent <Carrot> ();
         this.animator.SetBool("attackHand", true);
         car.launch(direction);
     }
 }
Exemplo n.º 18
0
 void launchCarrot(float direction)
 {
     if (Time.time - last_carrot > 2.0f)
     {
         this.last_carrot = Time.time;
         //Створюємо копію Prefab
         GameObject obj = GameObject.Instantiate(this.weapon);
         //Розміщуємо в просторі
         obj.transform.position = this.transform.position;
         //Запускаємо в рух
         Carrot carrot = obj.GetComponent <Carrot>();
         carrot.launch(direction);
     }
 }
Exemplo n.º 19
0
    void launchCarrot(float direction)
    {
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        obj.transform.SetParent(LevelController.objects.transform);

        var vector3 = this.transform.localPosition;

        vector3.y += 0.8f;

        obj.transform.localPosition = vector3;
        Carrot carrot = obj.GetComponent <Carrot>();

        carrot.launch(direction);
    }
Exemplo n.º 20
0
 void launchCarrot(Vector2 direction)
 {
     if (Time.time - last_carrot > carrotIntervalSeconds)
     {
         last_carrot = Time.time;
         //Створюємо копію Prefab
         GameObject obj = GameObject.Instantiate(this.prefabCarrot);
         //Розміщуємо в просторі
         obj.transform.position = this.transform.position;
         //Запускаємо в рух
         Carrot carrot = obj.GetComponent <Carrot> ();
         carrot.launch(direction);
         this.animator.SetTrigger("throw");
     }
 }
Exemplo n.º 21
0
    private IEnumerator launchCarrot()
    {
        Animator animator = GetComponent <Animator>();

        animator.SetBool("attack", true);
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        obj.transform.position = this.transform.position + (new Vector3(0f, 1f, 0f));
        Carrot carrot = obj.GetComponent <Carrot> ();

        carrot.launch(getDirection());
        yield return(new WaitForSeconds(0.8f));

        animator.SetBool("attack", false);
    }
Exemplo n.º 22
0
    void launchCarrot(float direction)
    {
        if (Time.time - last_carrot > carrotIntervalSeconds)
        {
            last_carrot = Time.time;
            animator.SetTrigger("attack");

            GameObject obj        = GameObject.Instantiate(this.prefabCarrot);
            Vector3    carrot_pos = this.transform.position;
            carrot_pos.y          += 1;
            obj.transform.position = carrot_pos;

            Carrot carrot = obj.GetComponent <Carrot>();
            carrot.launch(direction);
        }
    }
Exemplo n.º 23
0
 void launchCarrot(float direction)
 {
     if (Time.time - last_carrot > 2.0f)
     {
         if (SoundManager.Instance.isSoundOn())
         {
             attackSource.Play();
         }
         animator.SetTrigger("attack1");
         last_carrot = Time.time;
         GameObject obj = GameObject.Instantiate(this.prefabCarrot);
         obj.transform.position = this.transform.position;
         Carrot carrot = obj.GetComponent <Carrot> ();
         carrot.launch(direction);
         animator.SetTrigger("attack1");
     }
 }
Exemplo n.º 24
0
    void launchCarrot()
    {
        //Створюємо копію Prefab
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);

        obj.transform.position = this.transform.position;
        //Запускаємо в рух
        Carrot carrot = obj.GetComponent <Carrot>();
        float  direction;

        if (rabit_pos.x - my_pos.x < 0)
        {
            direction = 1;
        }
        else
        {
            direction = -1;
        }
        carrot.launch(direction);
    }
Exemplo n.º 25
0
    private void ThrowCarrot(GameObject rabbit)
    {
        base.StopAllAnimations();
        base.attacking = true;
        base.AnimateOnce("attack");


        //Створюємо копію Prefab
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);
        //Розміщуємо в просторі
        Vector3 positionForCarrot = this.transform.position;

        positionForCarrot.y += 0.75f;

        obj.transform.position = positionForCarrot;
        //Запускаємо в рух
        Carrot carrot = obj.GetComponent <Carrot> ();

        if (directionToThrowCarrot.x < 0)
        {
            carrot.gameObject.GetComponent <SpriteRenderer>().flipX = true;
        }
        carrot.launch(directionToThrowCarrot);
    }