示例#1
0
    void launchCarrot()
    {
        if (Time.time - last_carrot > 2.0f && HeroRabbit.rabbit_copy.getHealth() != 0 && !isDead())
        {
            //Створюємо копію Prefab
            GameObject   obj = GameObject.Instantiate(this.prefabCarrot);
            CarrotWeapon car = obj.GetComponent <CarrotWeapon> ();
            //	car.changePosition ();
            orgPos.y += 0.8f;
            obj.transform.position = orgPos;
            if (carrotDirectionLeft)
            {
                car.moveToLeft();
            }
            else
            {
                car.moveToRight();
            }

            last_carrot = Time.time;
        }
        else if (HeroRabbit.rabbit_copy.getHealth() == 0)
        {
            StartCoroutine(dieEffectLater());
        }
    }
    void launchCarrot(float direction)
    {
        //create Prefub copy
        GameObject obj = GameObject.Instantiate(this.prefabCarrot);
        Vector3    pos = this.transform.position;

        pos.y += 0.5f;
        obj.transform.position = pos;
        CarrotWeapon carrot = obj.GetComponent <CarrotWeapon> ();

        carrot.launch(direction);
    }