Ejemplo n.º 1
0
 public Player(Player player)
 {
     PlayerNumber = player.PlayerNumber;
     PlayerNumberReal = player.PlayerNumberReal;
     PlayerName = player.PlayerName;
     Kills = player.Kills;
     Lives = player.Lives;
     RespawnTimer = player.RespawnTimer;
     MissileLimit = player.MissileLimit;
     Missiles = new List<Missile>(player.Missiles);
     AlienWaveSize = player.AlienWaveSize;
     AlienManager = new AlienManager(player.AlienManager);
 }
Ejemplo n.º 2
0
        public Player(int playerNumber)
        {
            PlayerNumberReal = playerNumber; // Won't be flipped by CopyAndFlip
            PlayerNumber = playerNumber;
            PlayerName = "Player " + PlayerNumber;

            Kills = 0;
            Lives = Settings.Default.LivesInitial;
            RespawnTimer = 0;

            MissileLimit = Settings.Default.MissileLimitInitial;
            Missiles = new List<Missile>();

            AlienWaveSize = Settings.Default.AlienWaveSizeInitial;
            AlienManager = new AlienManager(PlayerNumber);
        }
        public AlienManager(AlienManager alienManager)
        {
            _debugAllMoveForward = alienManager._debugAllMoveForward;
            _debugAllShoot = alienManager._debugAllShoot;
            _debugPreventShoot = alienManager._debugPreventShoot;

            PlayerNumber = alienManager.PlayerNumber;
            Disabled = alienManager.Disabled;

            Waves = new List<List<Alien>>(alienManager.Waves.Count);
            foreach (var wave in alienManager.Waves)
            {
                Waves.Add(new List<Alien>(wave));
            }

            ShootStrategy = new ShootUsingRandomStrategy(Waves);
            ShotEnergyCost = alienManager.ShotEnergyCost;
            ShotEnergy = alienManager.ShotEnergy;
            DeltaX = alienManager.DeltaX;
        }
        public AlienManager(AlienManager alienManager)
        {
            _debugAllMoveForward = alienManager._debugAllMoveForward;
            _debugAllShoot       = alienManager._debugAllShoot;
            _debugPreventShoot   = alienManager._debugPreventShoot;

            PlayerNumber = alienManager.PlayerNumber;
            Disabled     = alienManager.Disabled;

            Waves = new List <List <Alien> >(alienManager.Waves.Count);
            foreach (var wave in alienManager.Waves)
            {
                Waves.Add(new List <Alien>(wave));
            }

            ShootStrategy  = new ShootUsingRandomStrategy(Waves);
            ShotEnergyCost = alienManager.ShotEnergyCost;
            ShotEnergy     = alienManager.ShotEnergy;
            DeltaX         = alienManager.DeltaX;
        }
        public static AlienManager CopyAndFlip(AlienManager alienManager, CoordinateFlipper flipper,
            Dictionary<int, Entity> flippedEntities)
        {
            var copy = new AlienManager(alienManager)
            {
                PlayerNumber = alienManager.PlayerNumber == 1 ? 2 : 1,
                DeltaX = -alienManager.DeltaX
            };

            // Clear default copy of waves
            foreach (var wave in copy.Waves)
            {
                wave.Clear();
            }
            copy.Waves.Clear();

            // Copy waves flipped
            for (var i = alienManager.Waves.Count - 1; i >= 0; i--)
            {
                var wave = alienManager.Waves[i];
                var waveList = new List<Alien>();
                copy.Waves.Add(waveList);

                foreach (var alien in wave)
                {
                    waveList.Add(Alien.CopyAndFlip(alien, flipper, flippedEntities));
                }
            }

            return copy;
        }