Exemple #1
0
        public override void InitGrid(HexGridManager <MapCell> grid, bool isPlaying)
        {
            MapController map = (MapController)grid;

            if (isPlaying && (unitPrefab != null) && (unitRecipe != null))
            {
                Debug.Log("Spawning " + count + " " + unitPrefab.name + " (" + unitRecipe.name + ")");
                for (int idx = 0; idx < count; idx++)
                {
                    MapUnit newUnit = Instantiate(unitPrefab);
                    newUnit.facing = HexFacingMethods.random;
                    newUnit.team   = team;
                    newUnit.LoadRecipe(unitRecipe);

                    HexCoords spawnLoc = map.coords
                                         .Where(unitPrefab.CanEnter)
                                         .Where(unitPrefab.CanStay)
                                         .RandomPick();

                    map.PlaceUnit(newUnit, spawnLoc);
                    foreach (MapCell cell in newUnit.GetThreatArea().Select(map.CellAt))
                    {
                        cell.AddThreat(newUnit);
                    }
                }
            }
        }
        public void PlaceUnit(MapUnit unit, MapCell cell)
        {
            if (cell.unitPresent != null)
            {
                throw new ArgumentException("Cell not empty!");
            }

            cell.unitPresent        = unit;
            unit.transform.parent   = cell.transform;
            unit.transform.position = cell.transform.position;
            unitIndex[unit]         = cell.loc;
        }
Exemple #3
0
        public IEnumerable <HexCoords> GetLandingArea(MapUnit target)
        {
            HexCoords targetLoc = map.WhereIs(target);

            if ((target.size == UnitSize.small) && (size == UnitSize.small))
            {
                return(targetLoc.Ring(1).Where(map.InBounds));
            }
            else
            {
                return(targetLoc.Ring(2).Where(map.InBounds));
            }
        }
Exemple #4
0
 public void Face(MapUnit unit)
 {
     Face(unit.loc);
 }
 public void UnplaceUnit(MapUnit unit)
 {
     CellAt(WhereIs(unit)).unitPresent = null;
     unit.transform.parent             = transform;
     unitIndex.Remove(unit);
 }
 public void PlaceUnit(MapUnit unit, HexCoords loc)
 {
     PlaceUnit(unit, CellAt(loc));
 }
 public MapCell UnitCell(MapUnit unit)
 {
     return(CellAt(WhereIs(unit)));
 }
 public HexCoords WhereIs(MapUnit unit)
 {
     return(unitIndex[unit]);
 }
 public bool HasUnit(MapUnit unit)
 {
     return(unitIndex.ContainsKey(unit));
 }
Exemple #10
0
 public void AddThreat(MapUnit threat)
 {
     threatSet.Add(threat);
     UpdatePresentation();
 }
Exemple #11
0
 public void RemoveThreat(MapUnit threat)
 {
     threatSet.Remove(threat);
     UpdatePresentation();
 }