Esempio n. 1
0
        /// <summary>
        /// creates an item for level.
        /// reads an item information file(.spec) and configures the item class.
        /// The read item class is stored in the list.
        /// </summary>
        /// <param name="info">item information for level</param>
        /// <param name="sceneParent">3D scene parent node</param>
        /// <returns>item class for the game</returns>
        protected GameItemBox CreateItemBox(ref ItemInLevel info,
                                            NodeBase sceneParent)
        {
            ItemBoxSpec spec = LoadItemSpec(ref info);

            GameItemBox item = new GameItemBox(spec);

            item.WorldTransform = Matrix.CreateTranslation(info.Position);
            item.SetRootAxis(Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f)));

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

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

            item.SetCollide(collide);

            item.EnableCulling  = true;
            item.ActiveFog      = true;
            item.ActiveLighting = false;

            //  adds item to the list.
            itemList.Add(item);

            //  adds item to parent scene node.
            sceneParent.AddChild(item);

            return(item);
        }
Esempio n. 2
0
        /// <summary>
        /// load all of the data for stage level, player, enemies, items, weapons, etc.
        /// </summary>
        /// <returns></returns>
        public void LoadLevel(string levelFile)
        {
            this.levelInfo = (GameLevelInfo)HelperFile.LoadData(levelFile,
                                                                levelInfo.GetType());

            RobotGameGame.CurrentGameLevel = this;

            //  Initialize level
            Initialize();

            //  Global fog
            if (levelInfo.FogEnable)
            {
                FrameworkCore.Viewer.BasicFog         = new RenderFog();
                FrameworkCore.Viewer.BasicFog.enabled = true;
                FrameworkCore.Viewer.BasicFog.start   = levelInfo.FogStart;
                FrameworkCore.Viewer.BasicFog.end     = levelInfo.FogEnd;

                FrameworkCore.Viewer.BasicFog.color = new Color(
                    (byte)levelInfo.FogColor.X,
                    (byte)levelInfo.FogColor.Y,
                    (byte)levelInfo.FogColor.Z);
            }
            else
            {
                FrameworkCore.Viewer.BasicFog         = new RenderFog();
                FrameworkCore.Viewer.BasicFog.enabled = false;
            }

            //  Global lighting
            if (levelInfo.LightingEnable)
            {
                FrameworkCore.Viewer.BasicLighting         = new RenderLighting();
                FrameworkCore.Viewer.BasicLighting.enabled = true;

                FrameworkCore.Viewer.BasicLighting.ambientColor = new Color(
                    (byte)levelInfo.LightingAmbientColor.X,
                    (byte)levelInfo.LightingAmbientColor.Y,
                    (byte)levelInfo.LightingAmbientColor.Z);

                FrameworkCore.Viewer.BasicLighting.diffuseColor = new Color(
                    (byte)levelInfo.LightingDiffuseColor.X,
                    (byte)levelInfo.LightingDiffuseColor.Y,
                    (byte)levelInfo.LightingDiffuseColor.Z);

                FrameworkCore.Viewer.BasicLighting.specularColor = new Color(
                    (byte)levelInfo.LightingSpecularColor.X,
                    (byte)levelInfo.LightingSpecularColor.Y,
                    (byte)levelInfo.LightingSpecularColor.Z);

                FrameworkCore.Viewer.BasicLighting.direction =
                    levelInfo.LightingDirection;
            }
            else
            {
                FrameworkCore.Viewer.BasicLighting         = new RenderLighting();
                FrameworkCore.Viewer.BasicLighting.enabled = false;
            }

            //  Create world
            if (this.levelInfo.WorldInLevel != null)
            {
                CreateWorld(ref this.levelInfo.WorldInLevel);
            }

            //  Create particles
            CreateParticle(this.levelInfo.ParticleListFile);

            //  Create player
            if (this.levelInfo.PlayerInLevel != null)
            {
                GamePlayer player = CreatePlayer(ref this.levelInfo.PlayerInLevel,
                                                 this.SceneMechRoot);

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

            //  Create all enemies in the level
            if (levelInfo.EnemyInLevelList != null)
            {
                for (int i = 0; i < levelInfo.EnemyInLevelList.Count; i++)
                {
                    EnemyInLevel enemy = levelInfo.EnemyInLevelList[i];

                    CreateSpawnEnemy(ref enemy, this.SceneMechRoot);
                }
            }

            //  Create all items in the level
            if (levelInfo.ItemInLevelList != null)
            {
                for (int i = 0; i < levelInfo.ItemInLevelList.Count; i++)
                {
                    ItemInLevel item = levelInfo.ItemInLevelList[i];

                    CreateItemBox(ref item, this.SceneWorldRoot);
                }
            }

            //  Create all weapons in the level
            if (levelInfo.WeaponInLevelList != null)
            {
                for (int i = 0; i < levelInfo.WeaponInLevelList.Count; i++)
                {
                    CreateWeapon(levelInfo.WeaponInLevelList[i], SceneWorldRoot);
                }
            }

            //  Entry collision of the units to layer in the level
            switch (Info.GamePlayType)
            {
            case GamePlayTypeId.StageClear:
            {
                GamePlayer player = SinglePlayer;

                //  Entry collision of the player to layer in the level
                CollisionLayerFriendlyMech.AddCollide(player.Collide);
                CollisionLayerAllMech.AddCollide(player.Collide);

                //  Entry collsion of each enemy to layer in the level
                for (int i = 0; i < EnemyCountInLevel; i++)
                {
                    GameEnemy enemy = GetEnemyInLevel(i);

                    CollisionLayerEnemyMech.AddCollide(enemy.Collide);
                    CollisionLayerAllMech.AddCollide(enemy.Collide);
                }
            }
            break;

            case GamePlayTypeId.Versus:
            {
            }
            break;
            }

            //  Entry collsion of items to layer in the level
            for (int i = 0; i < ItemCountInLevel; i++)
            {
                GameItemBox item = GetItemInLevel(i);

                CollisionLayerItems.AddCollide(item.Collide);
            }

            //  Entry collsion of weapons to layer in the level
            for (int i = 0; i < WeaponCountInLevel; i++)
            {
                GameWeapon weapon = GetWeaponInLevel(i);

                CollisionLayerItems.AddCollide(weapon.Collide);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// acquires the item on the world.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool ActionPickUpItem(GameItemBox item)
        {
            string message = "Pickup item";
            SoundTrack sound = SoundTrack.Count;

            switch (item.SpecData.Type)
            {
                case ItemType.RemedyBox:
                    {
                        if (this.IsFullLife)
                            return false;

                        message = "+ " + item.SpecData.RecoveryLife + "% ARMOR";

                        sound = SoundTrack.PickupRemedyBox;
                    }
                    break;
                case ItemType.MagazineBox:
                    {
                        //  The default weapon is must be machine gun
                        if (DefaultWeapon.WeaponType != WeaponType.PlayerMachineGun)
                            return false;

                        message = "+ " + item.SpecData.RecoveryBullet + " BULLETS";

                        sound = SoundTrack.PickupMagazine;
                    }
                    break;
            }

            //  Applies this item
            item.PickUp(this);

            //  Play the sound
            GameSound.Play3D(sound, RobotGameGame.SinglePlayer);

            //  Display item message to screen
            RobotGameGame.CurrentStage.DisplayPickup((int)this.PlayerIndex, message,
                3.0f);

            return true;
        }