Exemplo n.º 1
0
        // 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;
                    }
                }
            }
        }
Exemplo n.º 2
0
        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");
            }
        }
Exemplo n.º 3
0
 public override bool IsHostile(MapMobile other)
 {
     return(!(other is EnemyMobile));
 }
Exemplo n.º 4
0
 public abstract bool IsHostile(MapMobile other);
Exemplo n.º 5
0
 public bool HasMobile(MapMobile mobile)
 {
     return(mobilesPresent.Contains(mobile));
 }
Exemplo n.º 6
0
 public void RemoveMobile(MapMobile mobile)
 {
     mobilesPresent.Remove(mobile);
     __UpdatePresentation(true);
 }
Exemplo n.º 7
0
 public void AddMobile(MapMobile mobile)
 {
     mobilesPresent.Add(mobile);
     __UpdatePresentation(true);
 }
Exemplo n.º 8
0
 public override bool IsHostile(MapMobile other)
 {
     return(!(other is PlayerMobile));
 }
Exemplo n.º 9
0
 public void UnplaceMobile(MapMobile mobile)
 {
     mapGrid[WhereIs(mobile)].RemoveMobile(mobile);
 }
Exemplo n.º 10
0
 public void PlaceMobile(MapMobile mobile, PointyHexPoint point)
 {
     PlaceMobile(mobile, mapGrid[point]);
 }
Exemplo n.º 11
0
 public void PlaceMobile(MapMobile mobile, MapCell cell)
 {
     cell.AddMobile(mobile);
     mobile.transform.position          = cell.transform.position;
     mobile.spriteRenderer.sortingOrder = cell.spriteRenderer.sortingOrder + 1;
 }