Beispiel #1
0
        public TerrainTypes GetTerrainAt(RoomPosition pos)
        {
            TerrainTypes result  = TerrainTypes.Plain;
            var          terrain = _terrain.FirstOrDefault(t => t.Pos.Equals(pos));

            if (terrain != null)
            {
                result = terrain.Type;
            }

            return(result);
        }
Beispiel #2
0
        internal int GetRangeTo(RoomPosition pos)
        {
            int range     = int.MaxValue;
            var navigator = Room.GetNavigator();

            if (navigator != null)
            {
                var route = navigator.GetPath(this, pos);

                if (route != null && route.Path != null && route.Path.Count > 0)
                {
                    range = route.Path.Count;
                }
            }

            return(range);
        }
Beispiel #3
0
        // TODO: public List<RoomObject> Find( ? search )
        // why?: public Directions FindExitTo( Room target )
        // not encapsulated: public Route FindPath( RoomPosition from, RoomPosition to, object options = null )

        public RoomPosition GetPositionAt(int x, int y)
        {
            RoomPosition pos = null;

            if (x >= _terrain.Min(t => t.Pos.X) &&
                x <= _terrain.Max(t => t.Pos.X) &&
                y >= _terrain.Min(t => t.Pos.Y) &&
                y <= _terrain.Max(t => t.Pos.Y))
            {
                pos = new RoomPosition()
                {
                    X = x, Y = y, Room = this
                };
            }

            return(pos);
        }
Beispiel #4
0
 public Result CreateFlag(RoomPosition pos, string name = null, Color primary = default(Color), Color secondary = default(Color))
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 public Result CreateConstructionSite(RoomPosition pos, StructureTypes type)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public IReadOnlyList <RoomObject> LookAt(RoomPosition position)
 {
     return(Objects
            .Where(o => o.Pos.Equals(position))
            .ToList());
 }
Beispiel #7
0
 public Result ChooseSpawn(RoomPosition pos, Player owner, string name)
 {
     return(Server.ChooseSpawn(pos, owner, name));
 }
        internal override void UpdateTick()
        {
            base.UpdateTick();

            if (TimeToFinish > 0)
            {
                TimeToFinish--;
            }
            else if (Spawning != null)
            {
                log.Info(string.Format("Spawn of {0} complete", Spawning));
                // find an adjacent position that's not a wall
                RoomPosition pos         = null;
                bool         spotIsSwamp = false;

                for (int dx = -1; dx <= 1; dx++)
                {
                    for (int dy = -1; dy <= 1; dy++)
                    {
                        if (!(dx == 0 && dy == 0))
                        {
                            var test = Room.GetPositionAt(Pos.X + dx, Pos.Y + dy);

                            switch (Room.GetTerrainAt(test))
                            {
                            case TerrainTypes.Swamp:
                                // double check that the spot is empty
                                if (!Room.Objects.Any(o => o.Pos.Equals(test)))
                                {
                                    pos         = test;
                                    spotIsSwamp = true;
                                }
                                break;

                            case TerrainTypes.Plain:
                                if (!Room.Objects.Any(o => o.Pos.Equals(test)))
                                {
                                    pos         = test;
                                    spotIsSwamp = false;
                                }
                                break;
                            }

                            if (pos != null && !spotIsSwamp)
                            {
                                break;
                            }
                        }
                    }

                    if (pos != null && !spotIsSwamp)
                    {
                        break;
                    }
                }

                Creep baby = new Creep()
                {
                    Body         = Spawning.Body,
                    ID           = Game.Server.CreateID(),
                    Name         = Spawning.Name,
                    Owner        = this.Owner,
                    TicksToLive  = Game.Server.Configuration.CreepInfo.CreepLifeTime,
                    HitPoints    = 100,
                    HitPointsMax = 100,
                    Fatigue      = 0,
                    Game         = Game,
                    Pos          = pos ?? Pos,
                    Room         = Room,
                    Memory       = Spawning.Memory,
                };

                baby.Memory["#"] = 1;

                Game._objects.Add(baby);
                Game.Memory.Add(baby.ID, baby.Memory);

                Spawning = null;
            }

            if (Energy < EnergyCapacity)
            {
                Energy++;
            }
        }
Beispiel #9
0
 public Result MoveTo(RoomPosition pos, MoveOptions options = null)
 {
     return(Game.AddAction(new CreepMoveTo(this, pos, options)));
 }
Beispiel #10
0
 public Result SetPosition(RoomPosition pos)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public Route Search(RoomPosition origin, GameObject goal, SearchOptions options = null)
 {
     return(null);
 }