Exemple #1
0
        public void IncrementItemCount(ArmamentType itemType, SquadModel squadModel)
        {
            var targetItemArmament = squadModel.Items.Where(a => a.ArmamentType == itemType).FirstOrDefault();

            if (targetItemArmament != null)
            {
                var squads               = _gameState.Game.Players.Where(p => p.PlayerId == squadModel.PlayerId).FirstOrDefault().Squads;
                var itemArmamentList     = squads.SelectMany(s => s.Items.Where(a => a.ArmamentType == itemType).ToList());
                var existingItemArmament = itemArmamentList.Where(a => a.Count > 0).FirstOrDefault();

                if (existingItemArmament != null)
                {
                    if (!targetItemArmament.Equals(existingItemArmament))
                    {
                        existingItemArmament.SetCount(0);
                        targetItemArmament.SetCount(1);
                        CalculateSquadStats(squadModel);
                    }
                    else
                    {
                        _errorMessage.OnNext(ErrorType.InvalidAbilityCount.ToDescription());
                    }
                }
                else
                {
                    targetItemArmament.SetCount(1);
                    CalculateSquadStats(squadModel);
                }
            }
        }
Exemple #2
0
        public void DecrementArmamentCount(ArmamentType armamentType, SquadModel squadModel)
        {
            var armament = squadModel.Armaments.Where(a => a.ArmamentType == armamentType).FirstOrDefault();

            if (armament != null)
            {
                if (armament.Count - 1 >= 0)
                {
                    armament.SetCount(armament.Count - 1);
                    CalculateSquadStats(squadModel);
                }
                else
                {
                    if (armament.ArmamentType == _gameState.Game.PlayerId)
                    {
                        _errorMessage.OnNext(ErrorType.InvalidNamedHenchmanCount.ToDescription());
                    }
                    else
                    {
                        _errorMessage.OnNext(ErrorType.InvalidArmamentCount.ToDescription());
                    }
                }
            }
            else
            {
                _errorMessage.OnNext(ErrorType.InvalidArmamentType.ToDescription());
            }
        }
Exemple #3
0
        public void IncrementArmamentCount(ArmamentType armamentType, SquadModel squadModel)
        {
            var targetArmament          = squadModel.Armaments.Where(a => a.ArmamentType == armamentType).FirstOrDefault();
            var validTotalArmamentCount = 6;
            var totalArmamentCount      = squadModel.Armaments.Sum(a => a.Count);

            if (targetArmament != null)
            {
                if (totalArmamentCount + 1 <= validTotalArmamentCount)
                {
                    var playerArmamentType = _gameState.Game.PlayerId;

                    if (targetArmament.ArmamentType == _gameState.Game.PlayerId)
                    {
                        var playerId                      = _gameState.Game.PlayerId;
                        var squads                        = _gameState.Game.Players.Where(p => p.PlayerId == playerId).FirstOrDefault().Squads;
                        var playerArmamentList            = squads.SelectMany(s => s.Armaments.Where(a => a.ArmamentType == armamentType).ToList());
                        var existingNamedHenchmanArmament = playerArmamentList.Where(a => a.Count > 0).FirstOrDefault();

                        if (existingNamedHenchmanArmament != null)
                        {
                            if (!targetArmament.Equals(existingNamedHenchmanArmament))
                            {
                                existingNamedHenchmanArmament.SetCount(0);
                                targetArmament.SetCount(1);
                                CalculateSquadStats(squadModel);
                            }
                            else
                            {
                                _errorMessage.OnNext(ErrorType.InvalidNamedHenchmanCount.ToDescription());
                            }
                        }
                        else
                        {
                            targetArmament.SetCount(1);
                            CalculateSquadStats(squadModel);
                        }
                    }
                    else
                    {
                        targetArmament.SetCount(targetArmament.Count + 1);
                        CalculateSquadStats(squadModel);
                    }
                }
                else
                {
                    _errorMessage.OnNext(ErrorType.InvalidSquadSize.ToDescription());
                }
            }
            else
            {
                _errorMessage.OnNext(ErrorType.InvalidArmamentType.ToDescription());
            }
        }
        public IAGameObject MakeArmament(ArmamentType armamentType, Point firedFromPosition)
        {
            switch (armamentType)
            {
            case ArmamentType.Pulsecannon:
                return(new PulseCannon(_gameData, firedFromPosition));

            case ArmamentType.Missile:
                return(new Missile(_gameData, firedFromPosition));

            default:
                return(null);
            }
        }
Exemple #5
0
        public async Task DeleteGame(string gameId, ArmamentType playerId)
        {
            // NOTE: possible better solutions, but delete player when the player exits game,
            // if no more players exist, then delete game; checking on game load for
            // stale games would require a full table load, which would kill our
            // buffer on free data.

            await _context.DeleteAsync <PlayerDTO>(gameId, playerId);

            if ((await RequestPlayerList(gameId)).Count == 0)
            {
                await _context.DeleteAsync <GameDTO>(gameId);
            }
        }
Exemple #6
0
        private void Initialise()
        {
            _speedRange        = _aiModel.Speed;
            _headingAngleRange = (int)_aiModel.HeadingRange;
            _texturePath       = string.Format("Assets//Images//{0}", _aiModel.Texture);
            _framesPerSecond   = _gameData.FramesPerSecond;
            base.Strength      = _aiModel.Strength;
            base.MaxStrength   = _aiModel.Strength;
            _weaponType        = GetArmanamentType();

            _armoryType    = ArmoryType.AI;
            _armamentType  = _weaponType;
            FireAngle      = _aiModel.ScanRange;
            FiringClockSet = _aiModel.FireGranularity;
            AdjustFiringClock();
            _boundingBox = new BoundingBox(new Box {
                Left = 0, Top = 0, Width = _aiModel.Width, Height = _aiModel.Height
            });

            if (_aiModel.RandomStart.Contains("-1"))
            {
                SetRandomStartPosition();
            }
            else
            {
                _boundingBox = new BoundingBox(new Box {
                    Left = Double.Parse(_aiModel.RandomStart.Split(new char[] { ',' }).ToArray()[0]), Top = Double.Parse(_aiModel.RandomStart.Split(new char[] { ',' }).ToArray()[1]), Width = _aiModel.Width, Height = _aiModel.Height
                });
            }

            _gameObjectDim = new Size(_boundingBox.Dimension.Width, _boundingBox.Dimension.Height);
            SetupGameObject();
            _angle = GenerateRangedRandom(1, _headingAngleRange);

            HitbarInit(_aiModel.HitBarShow);

            _speed = _aiModel.Speed;
            if (_aiModel.Speed <= 0)
            {
                AutoSpeed();
            }

            ZIndex = 100;

            Update();
        }
Exemple #7
0
        public void DecrementAbilityCount(ArmamentType abilityType, SquadModel squadModel)
        {
            var ability = squadModel.Abilities.Where(a => a.ArmamentType == abilityType).FirstOrDefault();

            if (ability != null)
            {
                if (ability.Count - 1 >= 0)
                {
                    ability.SetCount(ability.Count - 1);
                    CalculateSquadStats(squadModel);
                }
                else
                {
                    _errorMessage.OnNext(ErrorType.InvalidAbilityCount.ToDescription());
                }
            }
            else
            {
                _errorMessage.OnNext(ErrorType.InvalidAbilityType.ToDescription());
            }
        }
Exemple #8
0
        public void DecrementItemCount(ArmamentType itemType, SquadModel squadModel)
        {
            var item = squadModel.Items.Where(a => a.ArmamentType == itemType).FirstOrDefault();

            if (item != null)
            {
                if (item.Count - 1 >= 0)
                {
                    item.SetCount(item.Count - 1);
                    CalculateSquadStats(squadModel);
                }
                else
                {
                    _errorMessage.OnNext(ErrorType.InvalidAbilityCount.ToDescription());
                }
            }
            else
            {
                _errorMessage.OnNext(ErrorType.InvalidItemType.ToDescription());
            }
        }
Exemple #9
0
        public async Task <bool> ChoosePlayer(ArmamentType playerId)
        {
            PlayerRequest request = new PlayerRequest
            {
                GameId   = _gameState.Game.GameId,
                PlayerId = playerId
            };

            if (!await _playerDataService.Exists(request))
            {
                var playerModel = GeneratePlayer(playerId);
                await _playerDataService.Create(playerModel);

                return(true);
            }
            else
            {
                _errorMessage.OnNext("Choose again!");
                return(false);
            }
        }
Exemple #10
0
        public void IncrementAbilityCount(ArmamentType abilityType, SquadModel squadModel)
        {
            ArmamentType playerArmamentType = _gameState.Game.PlayerId;

            if (playerArmamentType == ArmamentType.UgoDottore)
            {
                var targetAbilityArmament = squadModel.Abilities.Where(a => a.ArmamentType == abilityType).FirstOrDefault();

                if (targetAbilityArmament != null)
                {
                    var squads = _gameState.Game.Players.Where(p => p.PlayerId == squadModel.PlayerId).FirstOrDefault().Squads;
                    var abilityArmamentList     = squads.SelectMany(s => s.Abilities.Where(a => a.ArmamentType == abilityType).ToList());
                    var existingAbilityArmament = abilityArmamentList.Where(a => a.Count > 0).FirstOrDefault();

                    if (existingAbilityArmament != null)
                    {
                        if (!targetAbilityArmament.Equals(existingAbilityArmament))
                        {
                            existingAbilityArmament.SetCount(0);
                            targetAbilityArmament.SetCount(1);
                            CalculateSquadStats(squadModel);
                        }
                        else
                        {
                            _errorMessage.OnNext(ErrorType.InvalidAbilityCount.ToDescription());
                        }
                    }
                    else
                    {
                        targetAbilityArmament.SetCount(1);
                        CalculateSquadStats(squadModel);
                    }
                }
            }
            else
            {
                _errorMessage.OnNext(ErrorType.InvalidNamedHenchmanType.ToDescription());
            }
        }
Exemple #11
0
 public Armament(ArmamentType armamentType, ArmamentStats stats)
 {
     ArmamentType = armamentType;
     Stats        = stats;
 }
Exemple #12
0
 public Armament(ArmamentType armamentType)
 {
     ArmamentType = armamentType;
 }
Exemple #13
0
        private PlayerModel GeneratePlayer(ArmamentType playerId)
        {
            PlayerModel playerModel = new PlayerModel
            {
                GameId   = _gameState.Game.GameId,
                PlayerId = playerId,
                Squads   = new List <SquadModel>
                {
                    new SquadModel
                    {
                        PlayerId = playerId,
                        SquadId  = string.Format("{0}-1", playerId),
                    },
                    new SquadModel
                    {
                        PlayerId = playerId,
                        SquadId  = string.Format("{0}-2", playerId),
                    },
                    new SquadModel
                    {
                        PlayerId = playerId,
                        SquadId  = string.Format("{0}-3", playerId),
                    }
                }
            };

            foreach (SquadModel squad in playerModel.Squads)
            {
                ArmamentStats stats = new ArmamentStats();
                switch (playerId)
                {
                case ArmamentType.GeneralGoodman:
                    stats = new ArmamentStats(2, 2, 2, 2);
                    break;

                case ArmamentType.ArchibaldKluge:
                    stats = new ArmamentStats(0, 1, 3, 1);
                    break;

                case ArmamentType.AxleRobbins:
                    stats = new ArmamentStats(1, 0, 2, 2);
                    break;

                case ArmamentType.AzuraBadeau:
                    stats = new ArmamentStats(2, 2, 1, 0);
                    break;

                case ArmamentType.BorisMyasneek:
                    stats = new ArmamentStats(3, 1, 1, 0);
                    break;

                case ArmamentType.CassandraOShea:
                    stats = new ArmamentStats(0, 0, 2, 3);
                    break;

                case ArmamentType.EmmersonBarlow:
                    stats = new ArmamentStats(1, 3, 1, 0);
                    break;

                case ArmamentType.JinFeng:
                    stats = new ArmamentStats(0, 3, 1, 1);
                    break;

                case ArmamentType.TheNode:
                    stats = new ArmamentStats(0, 2, 2, 1);
                    break;

                case ArmamentType.UgoDottore:
                    stats = new ArmamentStats(1, 0, 3, 1);
                    break;
                }
                squad.Armaments.Add(new Armament(playerId, stats));
            }

            _gameState.Game.Players.Add(playerModel);
            _gameState.Game.PlayerId = playerId;;

            // Add chosen Named Henchman to first squad
            var firstSquad     = playerModel.Squads.Where(squad => squad.SquadId == string.Format("{0}-1", playerId)).FirstOrDefault();
            var playerArmament = firstSquad.Armaments.Where(armament => armament.ArmamentType == playerId).FirstOrDefault();

            playerArmament.SetCount(1);

            // Calculate stats for first squad
            _squadService.CalculateSquadStats(firstSquad);

            _thisPlayerUpdate.OnNext(playerModel);;

            return(playerModel);
        }
Exemple #14
0
        public async Task <PlayerDTO> RequestPlayer(string gameId, ArmamentType playerId)
        {
            var player = await _context.LoadAsync <PlayerDTO>(gameId, playerId);

            return(player);
        }
Exemple #15
0
        public async Task <bool> PlayerExists(string gameId, ArmamentType playerId)
        {
            var existingPlayer = await _context.LoadAsync <PlayerDTO>(gameId, playerId);

            return(existingPlayer != null);
        }