Пример #1
0
        public Level(ContentManager content, List <IRoomLayout> worlds, IPlayerObject hero, Dictionary <TextTypes, SpriteFont> spriteFonts, IEffectMusic effects)
        {
            this.effectMusic = effects;
            heroPlayer       = hero;
            this.worlds      = worlds;
            this.content     = content;
            opbouwSprites    = new SpriteGenerator(content);
            this.spriteFonts = spriteFonts;

            #region initialize all lists
            worldsTiles              = new List <List <ITile> >();
            worldsDoors              = new List <List <AStaticObject> >();
            worldsEnemys             = new List <List <AEnemyObject> >();
            worldsMoveEnemys         = new List <List <AEnemyMovement> >();
            worldsCollectables       = new List <List <ICollectableObject> >();
            worldsMoveCollectables   = new List <List <ACollectableMovement> >();
            currMovementEnemy        = new List <AEnemyMovement>();
            CurrMovementCollectables = new List <ACollectableMovement>();
            CurrEnemys      = new List <AEnemyObject>();
            CurrTiles       = new List <ITile>();
            CurrCollectable = new List <ICollectableObject>();
            currDoors       = new List <AStaticObject>();

            #endregion
            AMoveCommandFollowWhenNearby.HeroPlayer = heroPlayer;
            ACollectableMovement.HeroPlayer         = heroPlayer;
        }
Пример #2
0
 private void InitializeGameObjects()
 {
     #region initialize game music
     gameMusic = new GameMusic(musicGenerator);
     #endregion
     #region initialize Hero
     player = new Human(generateSprites.GetSpriteHuman(12), Vector2.Zero, fontGenerator.SpriteFonts, heroHearts, heroAttackDamage);
     #endregion
     #region initialize level1
     level1 = new Level(Content, levelsWorld1, player, fontGenerator.SpriteFonts, new EnemyEffects(musicGenerator));
     level1.CreateLevels();
     #endregion
     #region initialize hero movements
     moveHero = new MoveCommandHero(player, level1, keyBoardReader, new HumanEffect(musicGenerator));
     #endregion
     #region initialize camera animation
     _cameraAnimation = new CameraAnimatie((IInputSecredKeys)keyBoardReader);
     #endregion
     #region initialize menus
     startMenu = new StartMenu(fontGenerator.SpriteFonts, (IInputMenu)keyBoardReader, new Vector2(12, 2), startMenuItems);
     pauseMenu = new PauseMenu(fontGenerator.SpriteFonts, (IInputMenu)keyBoardReader, new Vector2(2, 2), pauseMenuItems);
     deadMenu  = new EndingGameMenu(fontGenerator.SpriteFonts, (IInputMenu)keyBoardReader, new Vector2(2, 2), deadMenuItems);
     endMenu   = new EndingGameMenu(fontGenerator.SpriteFonts, (IInputMenu)keyBoardReader, new Vector2((levelsWorld1[levelsWorld1.Count - 1].Warp1.X / 32) - 2, (levelsWorld1[levelsWorld1.Count - 1].Warp1.Y / 32) - 4), endMenuItems);
     #endregion
     #region initialize gameloop
     currGameState = GameLoop.Menu;
     #endregion
 }
Пример #3
0
 public void SetUp()
 {
     _playerObjectMock = MockRepository.GenerateMock <IPlayerObject>();
     _playerController = new PlayerController
     {
         PlayerObject = _playerObjectMock,
         Speed        = Speed,
     };
 }
Пример #4
0
 public AMovement(IPlayerObject player, Level level, IEffectMusic effects, float jumpHeight = 6f, float walkSpeed = 2f)
 {
     this.player       = player;
     this.level        = level;
     hasJumped         = true;
     isGround          = false;
     this.jumpHeight   = jumpHeight;
     this.walkingSpeed = walkSpeed;
     this.effects      = effects;
 }
Пример #5
0
        private void CheckPlayerDied(IPlayerObject playerObject)
        {
            var isDead = playerObject.Stats[StatType.Health] < 1;

            if (isDead)
            {
                SetStat(playerObject.Id, StatType.Health, 0);
                playerObject.IsDead = true;
                PlayerDiedEvent?.Invoke(this, playerObject.Id);
            }
        }
        public void NPCAttack(IPlayerObject enemy, AEnemyObject player, GameTime gametime, IEffectMusic effect)
        {
            SetTimer(gametime);

            if (NPCCollision.IsTouchingNPC(player.Rectangle, enemy.Rectangle))
            {
                if (gametime.TotalGameTime.TotalSeconds - timer > 0.7)
                {
                    effect.PlayAttack();
                    isSetTimer    = false;
                    enemy.Hearts -= player.AttackDamage;
                    if (!enemy.IsHit)
                    {
                        enemy.IsHit = true;
                        effect.PlayHit();
                    }
                }
            }
        }
        public void Attack(List <AEnemyObject> enemys, IPlayerObject player, GameTime gametime, IEffectMusic effect)
        {
            SetTimer(gametime);

            foreach (var enemy in enemys)
            {
                if (NPCCollision.IsTouchingNPC(player.Rectangle, enemy.Rectangle))
                {
                    if (gametime.TotalGameTime.TotalSeconds - timer > 0.5)
                    {
                        isSetTimer    = false;
                        enemy.Hearts -= player.AttackDamage;
                        if (!enemy.IsHit)
                        {
                            effect.PlayHit();
                            enemy.IsHit = true;
                        }
                    }
                }
            }
        }
Пример #8
0
 private int CalculateVampireBonus(IPlayerObject attacker, int actualDamage) =>
 Mathf.RoundToInt((float)attacker.Stats[StatType.Vampirism] / StatsMax * actualDamage);
Пример #9
0
 private int CalculateActualDamage(IPlayerObject defender, int damage) =>
 Mathf.RoundToInt((1.0f - (float)defender.Stats[StatType.Armor] / StatsMax) * damage);
Пример #10
0
 public MoveCommandHero(IPlayerObject player, Level level, IInputReader input, IEffectMusic effects) : base(player, level, effects)
 {
     inputs = input;
 }