コード例 #1
0
        private TreeStatusEnum BuildBarracks(GameEntity playa)
        {
            int        team = playa.team.value;
            GameEntity home = _allPlayers.BaseForTeam(team);

            if (home == null)
            {
                return(TreeStatusEnum.FAILURE);              //no home base => we are dead
            }
            List <HexCellBehaviour> hood = _grid.GetWithinRange(3, home.location.cell.cubeCoordinates);

            HexCellBehaviour buildLoc = null;

            while (hood.Count > 0)
            {
                //chose random cell
                int chosen = UnityEngine.Random.Range(0, hood.Count);
                buildLoc = hood[chosen];
                int cellid = buildLoc.GetComponent <EntitasLink>().id;

                //cell is empty?
                if (_game.GetEntitiesWithLocation(cellid).Count == 0)
                {
                }
                else
                {
                    hood.RemoveAt(chosen);
                }
            }
            return(TreeStatusEnum.FAILURE);
        }
コード例 #2
0
 public void Execute()
 {
     if (UnityEngine.Input.GetKeyDown(KeyCode.R))
     {
         foreach (var unit in _selectedUnitsWithWeapons)
         {
             foreach (var cell in _grid.GetWithinRange(unit.weapon.range, unit.location.cell.cubeCoordinates))
             {
                 cell.SetHighLight(true);
             }
         }
     }
     else if (UnityEngine.Input.GetKeyUp(KeyCode.R))
     {
         foreach (var unit in _selectedUnitsWithWeapons)
         {
             foreach (var cell in _grid.GetWithinRange(unit.weapon.range, unit.location.cell.cubeCoordinates))
             {
                 cell.SetHighLight(false);
             }
         }
     }
 }
コード例 #3
0
    public AutoAttackNearestBehaviour(GameContext game, GameEntity turret, HexGridBehaviour grid)
    {
        _game   = game;
        _turret = turret;
        _grid   = grid;

        inRange        = _grid.GetWithinRange(_turret.weapon.range, _turret.location.cell.cubeCoordinates);
        _CellIdInRange = new int[inRange.Count];
        for (int i = 0; i < _CellIdInRange.Length; ++i)
        {
            _CellIdInRange[i] = inRange[i].GetComponent <EntitasLink>().id;
        }

        _tree =
            new Sequence(
                new Selector(
                    new Action(KeepExistingTarget),
                    new Action(FindClosestEnemy)
                    ),
                new Action(AttackTarget)
                );
    }