Esempio n. 1
0
    //	public void Animate();
    public void AssesSituation()
    {
        UnitController targetEnemy = NpcController.NearestEnemy();

        if (targetEnemy != null && TargetSpotted != null)
        {
            TargetSpotted();
            //UnityEventManager.TriggerEvent("AlarmEvent");
        }
    }
Esempio n. 2
0
//	public void Animate();
    public void AssesSituation()
    {
        UnitController targetEnemy = NpcController.NearestEnemy();

        if (targetEnemy != null)
        {
            Vector3 enemyVector = targetEnemy.Location - NpcController.Location;
            Vector3 homeVector  = safeHouse.position - NpcController.Location;

            //if(enemyVector.magnitude<=10)
            if (enemyVector.magnitude < homeVector.magnitude / 2)
            {
                movement  = -enemyVector.normalized;
                animSpeed = 1f;
                NpcController.mover.Move(movement);
                bMovingToSafety = false;
                beingChased     = true;
            }
            else
            {
                beingChased = false;
            }
        }
        if (!beingChased && !bMovingToSafety)
        {
            //safeHouse = NpcBase.TargetNearest<Safety>(NpcController.Location,safeSpaces).transform;
            RunToSafety();
        }
        if (bMovingToSafety)
        {
            if (Vector3.Distance(NpcController.Location, safeHouse.position) >= 1f)
            {
                RunToSafety();
            }
            else
            {
                animSpeed       = 0f;
                bMovingToSafety = false;
                safeHouse.GetComponent <Safety>().EnterSafety(this.NpcController);
                if (NoLongerFleeing != null)
                {
                    NoLongerFleeing();
                }
                NpcController.gameObject.SetActive(false);
            }
        }
    }