Beispiel #1
0
        public SingleplayerGame(List<Cell> allCells)
            : base(allCells)
        {
            _aiPlayerInstance = new PlayerInstance("AI") { Id = -1 };
            Game.Instance.Players.Add(-1, _aiPlayerInstance);

            if (Ai.AiName == "Normal")
                _ai = new Normal(_aiPlayerInstance, allCells);
            else if(Ai.AiName == "Noob")
                _ai = new Noob(_aiPlayerInstance, allCells);

            _gameTimeCounter.Start();
        }
Beispiel #2
0
        public UnitCell(Cell targetCell, Cell sourceCell, int units, PlayerInstance player)
        {
            TargetCell = targetCell;
            SourceCell = sourceCell;
            Units = UnitsLeft = units;
            _currentVelocity = Velocity;

            string colorName = null;
            if (SourceCell.Player.Color.R == 255 && SourceCell.Player.Color.G == 0 && SourceCell.Player.Color.B == 0)
            {
                colorName = "red";
            }
            else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 255 && SourceCell.Player.Color.B == 0)
            {
                colorName = "green";
            }
            else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 0
                     && SourceCell.Player.Color.B == 255)
            {
                colorName = "blue";
            }

            _sprite = new Sprite(ResourceManager.Instance["game/unit_cell_" + colorName] as Texture);

            _text = new Text(units.ToString(), ResourceManager.Instance["fonts/verdana"] as Font, FontSize);
            _text.Origin = new Vector2f(
                _text.GetLocalBounds().Left + _text.GetLocalBounds().Width / 2,
                _text.GetLocalBounds().Top);

            _particleSystem = new ParticleSystem(ResourceManager.Instance["game/particle"] as Texture);

            var scale = 0.5f + Units * 0.0125f;
            if (scale >= 1f)
            {
                scale = 1f;
            }

            Scale = _initialScale = new Vector2f(scale, scale);

            Radius = _sprite.GetGlobalBounds().Height / 2;
            _sprite.Origin = new Vector2f(_sprite.GetLocalBounds().Width / 2, _sprite.GetLocalBounds().Height / 2);
            SourcePlayer = player;
        }
Beispiel #3
0
 public Noob(PlayerInstance aiPlayerInstance, List<Cell> allCells)
     : base(aiPlayerInstance, allCells)
 {
 }
Beispiel #4
0
 protected Ai(PlayerInstance aiPlayerInstance, List<Cell> allCells)
 {
     _aiPlayerInstance = aiPlayerInstance;
     _allCells = allCells;
 }
Beispiel #5
0
        private void ReadIniFile(string file)
        {
            var parser = new FileIniDataParser();
            var data = parser.ReadFile(file);

            Player = new PlayerInstance(data["Player"]["Nick"]);
            Ai.DecisionTime = TimeSpan.FromMilliseconds(Convert.ToDouble(data["AI"]["DecisionTime"]));
            Ai.AiName = data["AI"]["Type"];
            GameClient.GameClient.Instance.Ip = data["Server"]["IP"];
            GameClient.GameClient.Instance.Port = Convert.ToInt32(data["Server"]["Port"]);
        }
Beispiel #6
0
 private bool PlayerWon(PlayerInstance player)
 {
     return AllCells.Where(t => t.Player != null).All(t => t.Player.Id == player.Id)
            && Game.Instance.AllPlayers.Values.Except(new List<PlayerInstance> { player })
                   .All(t => t.UnitCells.Count == 0);
 }