Ejemplo n.º 1
0
        public void CheckMoveState(Dweller target)
        {
            if (!target)
            {
                return;
            }
            //Check if target has gone to far
            if (IsObjToFarToChase(target.Coords) && pursuit)
            {
                pursuit = false;
                movePath.Clear();
                currentSpeed = baseSpeed;
                return;
            }

            //Check if target to near
            if (Alarm(target.Coords) && !pursuit)
            {
                pursuit = true;
                movePath.Clear();
                if (target is MovingCharacter)
                {
                    currentSpeed = (target as MovingCharacter).Speed * speedDamper;
                }
            }
        }
Ejemplo n.º 2
0
 private void SearchPath(Dweller target)
 {
     if (target && pursuit)
     {
         movePath = Map.AStar(Coords, target.Coords);
     }
     else
     {
         if (!movePath.IsAny())
         {
             movePath = PatrolPath;
         }
     }
 }
Ejemplo n.º 3
0
 void OnCaughtByEnemy(Dweller killer)
 {
     GameOver?.Invoke(false);
     StartCoroutine(EndGame(delayForCoroutines));
 }
Ejemplo n.º 4
0
        public static List <T> CreateSet <T>(T prefab, LevelSettings settings, Transform parent = null, Dweller target = null) where T : Dweller
        {
            if (Dweller.Map == null)
            {
                Debug.LogError("Before create maze dwellers you should add maze map");
                return(null);
            }

            int distanceBetween;
            int amount;

            if (prefab is Enemy)
            {
                distanceBetween = (int)settings.AlertRange;
                amount          = settings.EnemiesAmount;
            }
            else if (prefab is Coin)
            {
                distanceBetween = settings.DistanceBetweenCoins;
                amount          = settings.СoinsAmount;
            }
            else
            {
                Debug.LogError("Behaviour for this type of Dweller aren't write yet");
                return(null);
            }


            var spawnPoints = Dweller.Map.GenerateSpawnPoints(distanceBetween, (prefab is Enemy)?Explorer.Graph.Distance.From : Explorer.Graph.Distance.Between, target.Coords);

            List <T> dwellers = new List <T>();
            T        dweller;

            for (int i = 0; i != amount; i++)
            {
                int id = Random.Range(0, spawnPoints.Count);
                dweller = Create(prefab, spawnPoints[id]);
                dweller.transform.parent = parent;
                dwellers.Add(dweller);
                if (dweller is Enemy)
                {
                    (dweller as Enemy).SetParams(settings.AlertRange, settings.ChaseRange, target);
                }
                spawnPoints.RemoveAt(id);
            }


            return(dwellers);
        }
Ejemplo n.º 5
0
 public void SetParams(float alertRange, float chaseRange, Dweller target)
 {
     this.alertRange = alertRange;
     this.chaseRange = chaseRange;
     targetCharacter = target;
 }
Ejemplo n.º 6
0
 public void StopGame()
 {
     targetCharacter = null;
     currentSpeed    = 0;
     movePath.Clear();
 }