// After grid instantiates public override void InitGrid() { // Reorder the cells for visual clarity foreach (PointyHexPoint point in Grid.CastValues <MapCell, PointyHexPoint>().ToPointList()) { mapGrid[point].spriteRenderer.sortingOrder = -point.Y; } // Only do map generation while the game is in play if (Application.isPlaying) { // Generate terrain PerlinTerrain(); // Spawn mobiles foreach (SpawnEntry spawn in spawnTable) { for (int idx = 0; idx < spawn.count; idx++) { MapMobile instance = Instantiate(spawn.prefab); PlaceMobile(instance, mapGrid.WhereCell(instance.CanSpawn).RandomPick()); instance.transform.parent = transform; } } } }
public PointyHexPoint WhereIs(MapMobile mobile) { PointList <PointyHexPoint> pointList = mapGrid.WhereCell(x => x.HasMobile(mobile)).ToPointList(); if (pointList.Count == 1) { return(pointList[0]); } else if (pointList.Count > 1) { throw new ArgumentOutOfRangeException("mobile", "Count > 1"); } else { throw new ArgumentOutOfRangeException("mobile", "Count <= 0"); } }
public override bool IsHostile(MapMobile other) { return(!(other is EnemyMobile)); }
public abstract bool IsHostile(MapMobile other);
public bool HasMobile(MapMobile mobile) { return(mobilesPresent.Contains(mobile)); }
public void RemoveMobile(MapMobile mobile) { mobilesPresent.Remove(mobile); __UpdatePresentation(true); }
public void AddMobile(MapMobile mobile) { mobilesPresent.Add(mobile); __UpdatePresentation(true); }
public override bool IsHostile(MapMobile other) { return(!(other is PlayerMobile)); }
public void UnplaceMobile(MapMobile mobile) { mapGrid[WhereIs(mobile)].RemoveMobile(mobile); }
public void PlaceMobile(MapMobile mobile, PointyHexPoint point) { PlaceMobile(mobile, mapGrid[point]); }
public void PlaceMobile(MapMobile mobile, MapCell cell) { cell.AddMobile(mobile); mobile.transform.position = cell.transform.position; mobile.spriteRenderer.sortingOrder = cell.spriteRenderer.sortingOrder + 1; }