Exemplo n.º 1
0
        /// <summary>
        /// creates a weapon for level.
        /// reads an weapon information file(.spec) and configures the weapon class.
        /// The read weapon class is stored in the list.
        /// </summary>
        /// <param name="info">weapon information for level</param>
        /// <param name="sceneParent">3D scene parent node</param>
        /// <returns>weapon class for the game</returns>
        protected GameWeapon CreateWeapon(WeaponInLevel info, NodeBase sceneParent)
        {
            GameWeaponSpec spec = new GameWeaponSpec();

            spec = (GameWeaponSpec)GameDataSpecManager.Load(info.SpecFilePath,
                                                            spec.GetType());

            GameWeapon weapon = new GameWeapon(spec);

            //  creates a collision data.
            Vector3 centerPos = Vector3.Transform(new Vector3(0f, spec.ModelRadius, 0f),
                                                  Matrix.Invert(weapon.RootAxis));

            CollideSphere collide = new CollideSphere(centerPos, spec.ModelRadius);

            weapon.SetCollide(collide);

            weapon.SetDroppedModelActiveFog(true);
            weapon.SetDroppedModelActiveLighting(false);

            //  drop to world.
            weapon.Drop(info.Position, sceneParent, null);

            //  adds a weapon to the list.
            weaponList.Add(weapon);

            return(weapon);
        }
Exemplo n.º 2
0
        /// <summary>
        /// loads an player's information using spec file (.spec).
        /// </summary>
        /// <param name="info">player information for level</param>
        /// <returns>player's spec information</returns>
        public static GamePlayerSpec LoadPlayerSpec(ref PlayerInLevel info)
        {
            //  loads a information of the spawn enemy.
            GamePlayerSpec spec = new GamePlayerSpec();

            spec = (GamePlayerSpec)GameDataSpecManager.Load(info.SpecFilePath,
                                                            spec.GetType());

            return(spec);
        }
Exemplo n.º 3
0
        /// <summary>
        /// loads an item's information using spec file (.spec).
        /// </summary>
        /// <param name="info">item information for level</param>
        /// <returns>item's spec information</returns>
        public static ItemBoxSpec LoadItemSpec(ref ItemInLevel info)
        {
            //  loads a spawn enemy information.
            ItemBoxSpec spec = new ItemBoxSpec();

            spec = (ItemBoxSpec)GameDataSpecManager.Load(info.SpecFilePath,
                                                         spec.GetType());

            return(spec);
        }
Exemplo n.º 4
0
        /// <summary>
        /// loads an enemy's information using spec file (.spec).
        /// </summary>
        /// <param name="info">enemy information for level</param>
        /// <returns>enemy's spec information</returns>
        public static GameEnemySpec LoadEnemySpec(ref EnemyInLevel info)
        {
            //  Load the spawn enemy information
            GameEnemySpec spec = new GameEnemySpec();

            spec = (GameEnemySpec)GameDataSpecManager.Load(info.SpecFilePath,
                                                           spec.GetType());

            return(spec);
        }
Exemplo n.º 5
0
        /// <summary>
        /// creates a weapon by spec file.
        /// </summary>
        /// <param name="specFileName">weapon information file (.spec)</param>
        public void CreateWeapon(string specFileName)
        {
            GameWeaponSpec spec = new GameWeaponSpec();

            spec =
                (GameWeaponSpec)GameDataSpecManager.Load(specFileName, spec.GetType());

            GameWeapon createWeapon = new GameWeapon(spec);

            createWeapon.AttachOwner(this);

            weaponList.Add(createWeapon);

            SelectWeapon(0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// creates a player character.
        /// </summary>
        /// <param name="specFileName">player spec file(.spec)</param>
        /// <param name="sceneParent">3D scene parent node</param>
        protected void CreatePlayer(string specFileName, NodeBase sceneParent)
        {
            GamePlayerSpec spec = new GamePlayerSpec();

            spec =
                (GamePlayerSpec)GameDataSpecManager.Load(specFileName, spec.GetType());

            GamePlayer player = null;

            switch (GameLevel.PlayerCountInLevel)
            {
            case 0:
            {
                player = new GamePlayer(ref spec, PlayerIndex.One);

                RobotGameGame.SinglePlayer = player;
                FrameworkCore.GameEventManager.TargetScene = player;
            }
            break;

            case 1:
            {
                player = new GamePlayer(ref spec, PlayerIndex.Two);
            }
            break;

            default:
                throw new InvalidOperationException(
                          "Added player count is overflow");
            }

            //  Entry enemies in 3D Scene root node
            sceneParent.AddChild(player);

            //  Create rotation axis
            Matrix rot = Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f));

            player.SetRootAxis(rot);

            //  Set material
            RenderMaterial material = new RenderMaterial();

            material.alpha         = 1.0f;
            material.diffuseColor  = new Color(210, 210, 210);
            material.specularColor = new Color(60, 60, 60);
            material.emissiveColor = new Color(30, 30, 30);
            material.specularPower = 24;

            material.vertexColorEnabled     = false;
            material.preferPerPixelLighting = false;

            player.Material       = material;
            player.ActiveFog      = true;
            player.ActiveLighting = true;

            //  Create collision data
            Vector3 centerPos = Vector3.Transform(
                new Vector3(0.0f, spec.MechRadius, 0.0f),
                Matrix.Invert(rot));

            CollideSphere collide = new CollideSphere(centerPos,
                                                      spec.MechRadius);

            player.EnableCulling = true;
            player.SetCollide(collide);
            player.ActionIdle();

            //  Add collide
            RobotGameGame.CurrentGameLevel.CollisionVersusTeam[
                GameLevel.PlayerCountInLevel].AddCollide(collide);

            RobotGameGame.CurrentGameLevel.CollisionLayerAllMech.AddCollide(collide);

            //  Set the respawn position
            if (player.PlayerIndex == PlayerIndex.One)
            {
                int count    = GameLevel.Info.RespawnInLevelList.Count;
                int rndIndex = HelperMath.Randomi(0, count);

                RespawnInLevel respawn = GameLevel.Info.RespawnInLevelList[rndIndex];

                player.SpawnPoint =
                    Matrix.CreateRotationY(MathHelper.ToRadians(respawn.SpawnAngle)) *
                    Matrix.CreateTranslation(respawn.SpawnPoint);
            }
            else if (player.PlayerIndex == PlayerIndex.Two)
            {
                GamePlayer gamePlayerOne = GameLevel.GetPlayerInLevel(0);

                RespawnInLevel respawn =
                    GameLevel.FindRespawnMostFar(gamePlayerOne.SpawnPoint.Translation);

                player.SpawnPoint =
                    Matrix.CreateRotationY(MathHelper.ToRadians(respawn.SpawnAngle)) *
                    Matrix.CreateTranslation(respawn.SpawnPoint);
            }

            GameLevel.AddPlayer(player);
        }