Ejemplo n.º 1
0
    private Transform FindClosestTarget()
    {
        float     sqrDistanceToTarget = -1;
        Transform currentTarget       = null;

        for (int i = 0; i < Fov.transformInSight.Count; i++)
        {
            BabySwanController bbController = Fov.transformInSight[i].GetComponent <BabySwanController>();
            if (bbController != null && bbController.alive)
            {
                if (sqrDistanceToTarget == -1)
                {
                    currentTarget       = Fov.transformInSight[i];
                    sqrDistanceToTarget = Vector3.SqrMagnitude(currentTarget.position - transform.position);
                }
                else if (Vector3.SqrMagnitude(Fov.transformInSight[i].position - transform.position) < sqrDistanceToTarget)
                {
                    sqrDistanceToTarget = Vector3.SqrMagnitude(Fov.transformInSight[i].position - transform.position);
                    currentTarget       = Fov.transformInSight[i];
                }
            }
        }

        return(currentTarget);
    }
Ejemplo n.º 2
0
    public void Enter()
    {
        controller = owner.GetComponent <EnnemyController>();
        controller.UpdateEnnemyMaterial(this.GetType());
        controller.MAX_VELOCITY = stateData.stateSpeed;

        eatenTarget      = controller.target;
        targetController = eatenTarget.GetComponent <BabySwanController>();
        targetController.StartBeingDragged();

        owner.GetComponent <EnnemySoundController>().StartEating();
    }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        BabySwanController controller = GetComponentInParent <BabySwanController>();

        if (controller != null)
        {
            controller.OnLoseLife += UpdateLifeBar;
            UpdateLifeBar(controller.Life);
        }
        else
        {
            Debug.Log("notfound");
        }
    }
Ejemplo n.º 4
0
 public void OnBabySaved(BabySwanController baby)
 {
     babySwanSaved.Add(baby);
     CheckIfWon();
 }
Ejemplo n.º 5
0
 public void OnBabyDies(BabySwanController baby)
 {
     babySwanDead.Add(baby);
     CheckIfGameOver();
     CheckIfWon();
 }