Exemplo n.º 1
0
        protected override bool FrameStarted(Mogre.FrameEvent evt)
        {
            if (reloadLevel)
            {
                levelView.Destroy();
                if (levelToLoad != null)
                {
                    currentLevel.Dispose();
                }
                SceneMgr.ClearScene();
                EffectsManager.Singleton.Clear();
                if (levelToLoad != null)
                {
                    filename     = levelToLoad;
                    currentLevel = new Level(filename, this, EngineConfig.CurrentPlayerPlaneType);
                }

                levelView = new LevelView(this, this);
                levelView.OnRegisterLevel(currentLevel);
                levelView.SetVisible(true);

                reloadLevel = false;
                levelToLoad = null;
                mainWindow.BeginInvoke(new InvokeDelegate(mainWindow.OnLevelLoaded), (currentLevel.LevelParser));

                foreach (ISceneTest test in this.gameTest.SceneTests)
                {
                    test.Framework = this;
                    test.OnRegisterLevel(currentLevel);
                }
            }


            if (base.FrameStarted(evt))
            {
                if (levelView != null)
                {
                    levelView.OnFrameStarted(evt);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        //The player class overrides the Update method. Update handles the changing of guns, reloading, and projectiles in the game.
        /// </summary>
        public override void Update(Mogre.FrameEvent evt)
        {
            model.Animate(evt);     //call the methods Animate from the model object
            controller.Update(evt); //in the Update method in the Player class call the Update method from the controller object

            timeElapsed += evt.timeSinceLastFrame;


            if (playerArmoury.GunChanged == true)
            {
                ((PlayerModel)model).AttachGun(playerArmoury.ActiveGun);

                playerArmoury.GunChanged = false;
            }

            if (controller.SwapGun == true && gunReloading == false) //if the player presses 'e'to swap gun and the current gun is not reloading
            {
                playerArmoury.SwapToNextGun();                       //swap to the next gun

                controller.setSwapGun(false);
            }
            else
            {
                controller.setSwapGun(false);
            }

            if (playerArmoury.ActiveGun != null && gunReloading == false)                                                             //if a gun has been picked up, and is not currently reloading
            {
                if (controller.Shoot && timeElapsed > playerArmoury.ActiveGun.ReloadTime() && playerArmoury.ActiveGun.Ammo.Value > 0) //if the player has ammo, presses shoot, and the gun is not cooling down between shots
                {
                    Shoot();                                                                                                          //shoot the gun
                    timeElapsed = 0f;                                                                                                 //and reset the cooldown timer of when the gun can be fired next
                }

                else if (playerArmoury.ActiveGun.Ammo.Value == 0) //else if the gun has no ammo
                {
                    gunReloading = true;                          //set gunReloading to true so can be displayed in GUI and begins the reload timer
                }
            }

            if (gunReloading == true)
            {
                reloadCooldownTime += evt.timeSinceLastFrame;
            }

            if (reloadCooldownTime > 2.5f)
            {
                playerArmoury.ActiveGun.ReloadAmmo();
                gunReloading       = false; //reset gunReloading to false
                reloadCooldownTime = 0;     //reset the reload timer
            }

            foreach (RaceGame.Projectile proj in projectiles)
            {
                // Console.Out.WriteLine(projectiles.Count);

                if (proj.TimeElapsed > 1)   //if ab
                {
                    //projectiles.Remove(proj);
                    projectilesToRemove.Add(proj);
                }
                else
                {
                    proj.Update(evt);
                }
            }


            foreach (RaceGame.Projectile proj in projectilesToRemove)
            {
                projectiles.Remove(proj);
            }
            projectilesToRemove.Clear();
        }
 protected override void Update(Mogre.FrameEvent evt) {
     //throw new NotImplementedException();
     _cameraCtl.UpdateCamera(evt.timeSinceLastFrame, base.Input);
 }