Пример #1
0
            internal override Model ReadEntry(BinaryReaderEx br)
            {
                ModelType type = br.GetEnum32 <ModelType>(br.Position + 8);

                switch (type)
                {
                case ModelType.MapPiece:
                    var mapPiece = new Model.MapPiece(br);
                    MapPieces.Add(mapPiece);
                    return(mapPiece);

                case ModelType.Object:
                    var obj = new Model.Object(br);
                    Objects.Add(obj);
                    return(obj);

                case ModelType.Enemy:
                    var enemy = new Model.Enemy(br);
                    Enemies.Add(enemy);
                    return(enemy);

                case ModelType.Player:
                    var player = new Model.Player(br);
                    Players.Add(player);
                    return(player);

                case ModelType.Collision:
                    var collision = new Model.Collision(br);
                    Collisions.Add(collision);
                    return(collision);

                default:
                    throw new NotImplementedException($"Unimplemented model type: {type}");
                }
            }
Пример #2
0
            internal override Model ReadEntry(BinaryReaderEx br)
            {
                ModelType type = br.GetEnum32 <ModelType>(br.Position + 8);

                switch (type)
                {
                case ModelType.MapPiece:
                    var mapPiece = new Model.MapPiece(br);
                    MapPieces.Add(mapPiece);
                    return(mapPiece);

                case ModelType.Object:
                    var obj = new Model.Object(br);
                    Objects.Add(obj);
                    return(obj);

                case ModelType.Enemy:
                    var enemy = new Model.Enemy(br);
                    Enemies.Add(enemy);
                    return(enemy);

                // Potential from mistake in m36 :trashcat:
                case ModelType.Item:
                    var item = new Model.Item(br);
                    Items.Add(item);
                    return(item);

                case ModelType.Player:
                    var player = new Model.Player(br);
                    Players.Add(player);
                    return(player);

                case ModelType.Collision:
                    var collision = new Model.Collision(br);
                    Collisions.Add(collision);
                    return(collision);

                case ModelType.Navmesh:
                    var navmesh = new Model.Navmesh(br);
                    Navmeshes.Add(navmesh);
                    return(navmesh);

                case ModelType.Other:
                    var other = new Model.Other(br);
                    Others.Add(other);
                    return(other);

                default:
                    throw new NotImplementedException($"Unsupported model type: {type}");
                }
            }
            internal override Model ReadEntryBB(BinaryReaderEx br)
            {
                ModelType type = br.GetEnum32 <ModelType>(br.Position + 8);

                switch (type)
                {
                case ModelType.MapPiece:
                    var mapPiece = new Model.MapPiece(br, MSBVersion.MSBVersionBB);
                    MapPieces.Add(mapPiece);
                    return(mapPiece);

                case ModelType.Object:
                    var obj = new Model.Object(br, MSBVersion.MSBVersionBB);
                    Objects.Add(obj);
                    return(obj);

                case ModelType.Enemy:
                    var enemy = new Model.Enemy(br, MSBVersion.MSBVersionBB);
                    Enemies.Add(enemy);
                    return(enemy);

                case ModelType.Item:
                    var enemy2 = new Model.Enemy(br);
                    Enemies.Add(enemy2);
                    return(enemy2);

                case ModelType.Player:
                    var player = new Model.Player(br, MSBVersion.MSBVersionBB);
                    Players.Add(player);
                    return(player);

                case ModelType.Collision:
                    var collision = new Model.Collision(br, MSBVersion.MSBVersionBB);
                    Collisions.Add(collision);
                    return(collision);

                /*
                 * case ModelType.Other:
                 * var other = new Model.Other(br);
                 * Others.Add(other);
                 * return other;
                 */
                default:
                    return(null);

                    //throw new NotImplementedException($"Unsupported model type: {type}");
                }
            }
Пример #4
0
        public void Set(Model.Enemy model, Player player, bool updateCurrentHP)
        {
            base.Set(model, updateCurrentHP);

            _disposablesForModel.DisposeAllAndClear();

            UpdateArmor();

            _player = player;

            StartRun();

            if (!ShowSpeech("ENEMY", model.RowData.Id))
            {
                ShowSpeech("ENEMY_INIT", model.spawnIndex);
            }
        }
Пример #5
0
        internal void MoveToTarget(Model.Enemy a_enemy, Vector2 a_target)
        {
            //
            Vector2 moveTo   = a_target;
            Vector2 newCords = Vector2.Zero;

            float xSpeed = 0;
            float ySpeed = 0;

            if (a_enemy.IsAttacking)
            {
                moveTo.X = a_enemy.Target.ThisUnit.Bounds.X + a_enemy.TargetDisLocationX;
                moveTo.Y = a_enemy.Target.ThisUnit.Bounds.Y + a_enemy.TargetDisLocationY;
            }
            if (a_enemy.IsEvading)
            {
                moveTo.X = a_enemy.SpawnPosition.X;
                moveTo.Y = a_enemy.SpawnPosition.Y;
            }

            a_enemy.Direction = new Vector2(moveTo.X - a_enemy.ThisUnit.Bounds.Center.X, moveTo.Y - a_enemy.ThisUnit.Bounds.Center.Y);

            xSpeed = Math.Abs(a_enemy.Direction.X);
            ySpeed = Math.Abs(a_enemy.Direction.Y);

            if (!ArrivedToPosition(a_enemy.ThisUnit.Bounds, moveTo, 5) && (a_enemy.Target != null && !a_enemy.ThisUnit.Bounds.Intersects(a_enemy.Target.ThisUnit.Bounds) || a_enemy.IsEvading))
            {
                newCords = a_enemy.Direction;
                newCords.Normalize();
                newCords.X = newCords.X * a_enemy.MoveSpeed;
                newCords.Y = newCords.Y * a_enemy.MoveSpeed;
                xSpeed     = Math.Abs(a_enemy.Direction.X);
                ySpeed     = Math.Abs(a_enemy.Direction.Y);

                a_enemy.ThisUnit.Bounds.X += (int)newCords.X;
                a_enemy.ThisUnit.Bounds.Y += (int)newCords.Y;

                if (xSpeed > ySpeed)
                {
                    if (a_enemy.Direction.X > 0f)
                    {
                        a_enemy.UnitState   = View.AnimationSystem.MOVING_RIGHT;
                        a_enemy.WeaponState = a_enemy.UnitState;
                    }
                    else
                    {
                        a_enemy.UnitState   = View.AnimationSystem.MOVING_LEFT;
                        a_enemy.WeaponState = a_enemy.UnitState;
                    }
                }
                else
                {
                    if (a_enemy.Direction.Y > 0f)
                    {
                        a_enemy.UnitState   = View.AnimationSystem.MOVING_DOWN;
                        a_enemy.WeaponState = a_enemy.UnitState;
                    }
                    else
                    {
                        a_enemy.UnitState   = View.AnimationSystem.MOVING_UP;
                        a_enemy.WeaponState = a_enemy.UnitState;
                    }
                }
            }
            else
            {
                if (xSpeed > ySpeed)
                {
                    if (a_enemy.Direction.X > 0f)
                    {
                        a_enemy.UnitState   = View.AnimationSystem.FACING_RIGHT;
                        a_enemy.WeaponState = View.AnimationSystem.MOVING_RIGHT;
                    }
                    else
                    {
                        a_enemy.UnitState   = View.AnimationSystem.FACING_LEFT;
                        a_enemy.WeaponState = View.AnimationSystem.MOVING_LEFT;
                    }
                }
                else
                {
                    if (a_enemy.Direction.Y > 0f)
                    {
                        a_enemy.UnitState   = View.AnimationSystem.FACING_CAMERA;
                        a_enemy.WeaponState = View.AnimationSystem.MOVING_DOWN;
                    }
                    else
                    {
                        a_enemy.UnitState   = View.AnimationSystem.FACING_AWAY;
                        a_enemy.WeaponState = View.AnimationSystem.MOVING_UP;
                    }
                }

                a_enemy.IsEvading = false;
            }
        }
        //Metod för utritning av NPCs avatars samt deras mana/hp
        private void DrawTargetAvatars()
        {
            //Ritar bakgrunden till hp/mana.
            Rectangle pBackgroundRect = new Rectangle(110, 30, 169, 36);

            //RITAR SPELARENS HP.
            int       playerHpWidth = CalculateHp(m_player);
            Rectangle playerHpRect  = new Rectangle(105, 47, playerHpWidth, 16);

            m_spriteBatch.Draw(m_textures[GREEN_HP], playerHpRect, Color.White);

            //RITAR SPELARENS MANA.
            int       playerManaWidth = CalculateMana(m_player);
            Rectangle playerManaRect  = new Rectangle(105, 63, playerManaWidth, 16);

            m_spriteBatch.Draw(m_textures[MANA], playerManaRect, Color.White);

            //healthbar PROFILBILD.
            m_spriteBatch.Draw(m_textures[AVATAR_PLAYER], new Vector2(0, 0), Color.White);


            if (m_player.Target != null)
            {
                Texture2D target;
                Texture2D hp;

                if (m_player.Target.GetType() == Model.GameModel.ENEMY_NPC)
                {
                    hp = m_textures[RED_HP];

                    if (m_player.Target.Type == Model.Enemy.CLASS_WARRIOR)
                    {
                        target = m_textures[AVATAR_KNIGHT];
                    }
                    else if (m_player.Target.Type == Model.Enemy.CLASS_GOBLIN)
                    {
                        target = m_textures[AVATAR_GOBLIN];
                    }
                    else if (m_player.Target.Type == Model.Enemy.CLASS_MAGE)
                    {
                        target = m_textures[AVATAR_FIREMAGE];
                    }
                    else if (m_player.Target.Type == Model.Enemy.BOSS_A)
                    {
                        target = m_textures[AVATAR_BRYNOLF];
                    }
                    else
                    {
                        target = m_textures[AVATAR_GOBLIN];
                    }
                }
                else if (m_player.Target.Type == Model.Friend.CITY_GUARD)
                {
                    target = m_textures[AVATAR_CITY_GUARD];
                    hp     = m_textures[GREEN_HP];
                }
                else
                {
                    target = m_textures[AVATAR_OLD_MAN];
                    hp     = m_textures[GREEN_HP];
                }

                //Målar ut targeten.
                //Ritar bakgrunden till hp/mana.
                Rectangle eBackgroundRect = new Rectangle(410, 30, 169, 36);

                //RITAR FIENDENS HP.
                int       enemyHpWidth = CalculateHp(m_player.Target);
                Rectangle enemyHpRect  = new Rectangle(407, 47, enemyHpWidth, 16);
                m_spriteBatch.Draw(hp, enemyHpRect, Color.White);

                //RITAR FIENDENS MANA.
                if (m_player.Target.GetType() == Model.GameModel.ENEMY_NPC)
                {
                    Model.Enemy enemy = m_player.Target as Model.Enemy;
                    if (enemy.Type == Model.Enemy.CLASS_MAGE || enemy.Type == Model.Enemy.BOSS_A)
                    {
                        int       enemyManaWidth = CalculateMana(m_player.Target);
                        Rectangle enemyManaRect  = new Rectangle(407, 63, enemyManaWidth, 16);
                        m_spriteBatch.Draw(m_textures[MANA], enemyManaRect, Color.White);
                    }
                }

                m_spriteBatch.Draw(target, new Vector2(300, 0), Color.White);
            }
        }
Пример #7
0
 private static IEnumerator CoSpawnMonster(Model.Enemy enemy, Vector2 pos, Character.Player player)
 {
     EnemyFactory.Create(enemy, pos, player);
     yield return(new WaitForSeconds(UnityEngine.Random.Range(0.0f, 0.2f)));
 }
Пример #8
0
 public void SetData(Model.Enemy enemy)
 {
     _enemy = enemy;
     SpawnWave();
 }
Пример #9
0
        /// <summary>
        /// Method for drawing avatar icons and their health and mana pools
        /// </summary>
        public void DrawTargetAvatars()
        {
            Rectangle pBackgroundRect = new Rectangle(110, 30, 169, 36);

            //Player hp
            int       playerHpWidth = CalculateHp(_player);
            Rectangle playerHpRect  = new Rectangle(105, 47, playerHpWidth, 16);

            _spriteBatch.Draw(_avatarTextures[Convert.ToInt32(Texture.GREEN_HP)], playerHpRect, Color.White);

            //Player mana
            int       playerManaWidth = CalculateMana(_player);
            Rectangle playerManaRect  = new Rectangle(105, 63, playerManaWidth, 16);

            _spriteBatch.Draw(_avatarTextures[Convert.ToInt32(Texture.MANA)], playerManaRect, Color.White);

            //Healthbar
            _spriteBatch.Draw(_avatarTextures[Convert.ToInt32(Texture.AVATAR_PLAYER)], new Vector2(0, 0), Color.White);

            if (_player.Target != null)
            {
                Texture2D target;
                Texture2D hp;

                if (_player.Target.GetType() == Model.GameModel.ENEMY_NPC)
                {
                    hp = _avatarTextures[Convert.ToInt32(Texture.RED_HP)];

                    if (_player.Target.Type == Model.Enemy.CLASS_WARRIOR)
                    {
                        target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_KNIGHT)];
                    }

                    else if (_player.Target.Type == Model.Enemy.CLASS_GOBLIN)
                    {
                        target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_GOBLIN)];
                    }

                    else if (_player.Target.Type == Model.Enemy.CLASS_MAGE)
                    {
                        target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_FIREMAGE)];
                    }

                    else if (_player.Target.Type == Model.Enemy.BOSS_A)
                    {
                        target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_BRYNOLF)];
                    }

                    else
                    {
                        target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_GOBLIN)];
                    }
                }
                else if (_player.Target.Type == Model.NonPlayerCharacter.CITY_GUARD)
                {
                    target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_CITY_GUARD)];
                    hp     = _avatarTextures[Convert.ToInt32(Texture.GREEN_HP)];
                }
                else
                {
                    target = _avatarTextures[Convert.ToInt32(Texture.AVATAR_OLD_MAN)];
                    hp     = _avatarTextures[Convert.ToInt32(Texture.GREEN_HP)];
                }

                //Rendering target avatar
                Rectangle eBackgroundRect = new Rectangle(410, 30, 169, 36);

                //Target hp
                int       enemyHpWidth = CalculateHp(_player.Target);
                Rectangle enemyHpRect  = new Rectangle(407, 47, enemyHpWidth, 16);
                _spriteBatch.Draw(hp, enemyHpRect, Color.White);

                //Target mana
                if (_player.Target.GetType() == Model.GameModel.ENEMY_NPC)
                {
                    Model.Enemy enemy = _player.Target as Model.Enemy;
                    if (enemy.Type == Model.Enemy.CLASS_MAGE || enemy.Type == Model.Enemy.BOSS_A)
                    {
                        int       enemyManaWidth = CalculateMana(_player.Target);
                        Rectangle enemyManaRect  = new Rectangle(407, 63, enemyManaWidth, 16);
                        _spriteBatch.Draw(_avatarTextures[Convert.ToInt32(Texture.MANA)], enemyManaRect, Color.White);
                    }
                }

                _spriteBatch.Draw(target, new Vector2(300, 0), Color.White);
            }
        }