Example #1
0
 // Update is called once per frame
 void Update()
 {
     //transições
     if (_chased == null)
     {
         _fish.ChangeState(this.gameObject.GetComponent <RoamState>());
     }
 }
Example #2
0
    void Start()
    {
        cam = GetComponent <Camera>();

        fish.SetGod(this);
        fish.MakeSons(fishPrefabs);
        fish.ChangeState(FishState.Vibing);
        gameEnd = fishPrefabs.Count;

        ScrambleFish();

        for (int i = 0; i < maxFood; i++)
        {
            Food newFood = GameObject.Instantiate(foodPrefab);
            newFood.SetGod(this);
            readyFoods.Add(newFood);
        }
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        //behaviour
        //anda por aí, procurando por comida(pela função OnTriggerEnter2D)

        //se saiu da visão da camêra, aponta para o centro:

        if (!_renderer.isVisible)
        {
            //pos final menos inicial
            Vector3 point = Vector3.zero - this.transform.position;
            //angulo em graus
            float angle = Mathf.Atan2(point.y, point.x) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.Euler(0.0f, 0.0f, angle);
        }
        else
        {
            t += Time.deltaTime;
            if (t > ChangeDirectionTimer)
            {
                t = 0.0f;
                transform.Rotate(0.0f, 0.0f, Random.Range(-MaxRotationAngle, MaxRotationAngle));
            }
        }


        //transição

        if (_foundFood != null)
        {
            //se achou comida menor que si mesmo, persegue
            if (_food.FoodValue > _foundFood.FoodValue)
            {
                _cs._chased = _foundFood.gameObject;
                _fish.ChangeState(_cs);
            }
            else if (_food.FoodValue < _foundFood.FoodValue)
            {
                //to do
            }
        }
    }