Пример #1
0
        private static void RenderSpawn(Graphics g, Client.StructureSpawn spn, RectangleF boundry)
        {
            g.DrawEllipse(Pens.White, boundry);

            // energy storage
            boundry.Inflate(-3, -3);
            g.FillEllipse(Brushes.DarkBlue, boundry);

            if (spn.EnergyCapacity != 0 && spn.Energy > 0)
            {
                float nrgPercent = 1 - (spn.Energy / (float)spn.EnergyCapacity);
                float inflatex   = (boundry.Width * (nrgPercent / 2) * -1);
                float inflatey   = (boundry.Height * (nrgPercent / 2) * -1);

                if (inflatex != 0 && inflatey != 0)
                {
                    boundry.Inflate(inflatex, inflatey);
                }

                g.FillEllipse(Brushes.Yellow, boundry);
            }
        }
Пример #2
0
        internal Result ChooseSpawn(RoomPosition pos, Player owner, string name)
        {
            var result = new Result()
            {
                TypeID = ResultTypes.UnknownError
            };

            // must be a real position
            if (pos != null && pos.Room != null)
            {
                // must be on a plain
                if (pos.Room.GetTerrainAt(pos) == TerrainTypes.Plain)
                {
                    var spawn = new Client.StructureSpawn()
                    {
                        Owner          = owner,
                        Pos            = pos,
                        Room           = pos.Room,
                        Energy         = Configuration.SpawnInfo.EnergyCapacity,
                        EnergyCapacity = Configuration.SpawnInfo.EnergyCapacity,
                        ID             = CreateID(),
                        Game           = pos.Room.Game,
                        HitPoints      = Configuration.SpawnInfo.HitPoints,
                        HitPointsMax   = Configuration.SpawnInfo.HitPoints,
                        Name           = name,
                        Type           = StructureTypes.Spawn,

                        Memory = new Dictionary <string, object>(),
                    };

                    pos.Room.Game._objects.Add(spawn);
                    pos.Room.Game.Memory.Add(spawn.ID, spawn.Memory);
                    result = new Result()
                    {
                        TypeID = ResultTypes.Success
                    };

                    FireEvent(pos.Room, new GameEventArgs()
                    {
                        Type = GameEventTypes.RoomChanged, Message = string.Format("Spawn {0} Created", name)
                    });

                    // TODO: Check for any other requirements before game start
                    Start();
                }
                else
                {
                    result = new Result()
                    {
                        TypeID = ResultTypes.SpawnMustBeOnAPlain
                    };
                }
            }
            else
            {
                result = new Result()
                {
                    TypeID = ResultTypes.InvalidPoint
                };
            }

            return(result);
        }