Example #1
0
        public Turn Iteration(LevelView level, IMessageReporter messageReporter, out bool isAttack)
        {
            isAttack = false;
            var             monsterMap = new EnemyMap(level, 1);
            var             trapMap    = new TrapMap(level);
            var             travelMap  = Map.Sum(trapMap, WallMap);
            var             pathMap    = Map.Sum(monsterMap, travelMap);
            List <Location> path       = null;

            if (level.Player.Health < 50 && level.HealthPacks.Any())
            {
                path = pathMap.FindPath(level.Player.Location, level.HealthPacks.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
                messageReporter.ReportMessage("Healing");
            }
            else if (level.Monsters.Any(m => m.Location.IsInRange(level.Player.Location, 1)))
            {
                messageReporter.ReportMessage("Attack");
                isAttack = false;
                return(Turn.Attack(level.Monsters.First(m => m.Location.IsInRange(level.Player.Location, 1)).Location - level.Player.Location));
            }
            else if (level.Monsters.Any())
            {
                int i = 0;
                path = travelMap.FindPath(level.Player.Location, level
                                          .Monsters.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
                if (i > 10)
                {
                    return(Turn.None);
                }
                messageReporter.ReportMessage("Far attack");
            }
            else if (level.Player.Health < 100 && level.HealthPacks.Any())
            {
                messageReporter.ReportMessage("100 Healing");
                path = pathMap.FindPath(level.Player.Location, level.HealthPacks.OrderBy(h => h.Location.Distance(level.Player.Location)).First().Location);
            }
            else if (Math.Max(BestItem(level).AttackBonus, BestItem(level).DefenceBonus) > Math.Max(level.Player.TotalAttack - level.Player.Attack, level.Player.TotalDefence - level.Player.Defence))
            {
                path = pathMap.FindPath(level.Player.Location, BestItem(level).Location);
            }
            else
            {
                messageReporter.ReportMessage("Leave");
                var leaveMap = Map.Sum(travelMap, new BadObjectMap(level, (view, location) => level.Items.Any(i => i.Location.Equals(location)), view => level.Items.Select(i => i.Location), 1));
                path = leaveMap.FindPath(level.Player.Location, Exit);
            }
            if (path != null)
            {
                return(Turn.Step(path[1] - path[0]));
            }
            return(Turn.None);
        }
 // Start is called before the first frame update
 void Start()
 {
     _beatController = BeatController.GetInstance();
     _beatController.BeatSubject.AddObserver(this);
     _inputManager = InputManager.GetInstance();
     changeDirection(_currentDirection);
     Debug.Log("Starting animation");
     _grid                = GameObject.FindGameObjectWithTag("TileGrid").GetComponent <Grid>();
     _collisionMap        = GameObject.FindGameObjectWithTag("ColliderMap").GetComponent <Tilemap>();
     _goalMap             = GameObject.FindGameObjectWithTag("GoalMap").GetComponent <Tilemap>();
     _trapMap             = GameObject.FindGameObjectWithTag("TrapMap").GetComponent <TrapMap>();
     _currentTrapTileList = new List <GameObject>();
 }
Example #3
0
        public Enviroment(LevelView level, int enemyRadius = 4, int trapRadius = 1, WallMap wallMap = null, int wallRadius = 4)
        {
            if (wallMap == null)
            {
                wallMap = new WallMap(level, wallRadius);
            }
            WallMap  = wallMap;
            TrapMap  = new TrapMap(level, trapRadius);
            EnemyMap = new EnemyMap(level, enemyRadius);

            Exit  = level.Field.GetCellsOfType(CellType.Exit).First();
            Start = level.Field.GetCellsOfType(CellType.PlayerStart).First();
        }
Example #4
0
 public void Update(LevelView level, int enemyRadius = 4, int trapRadius = 1)
 {
     TrapMap  = new TrapMap(level, trapRadius);
     EnemyMap = new EnemyMap(level, enemyRadius);
     FillAdditionMaps(level);
 }