/*public void OpenDeathMenu() * { * new DeathMenu(this.mStateMgr); * this.SwitchGUIVisibility(true); * this.mTimeSinceGUIOpen.Reset(); * }*/ public void SwitchFreeCamMode() { VanillaPlayer mainPlayer = this.mStateMgr.MainState.CharacMgr.MainPlayer; if (mainPlayer == null) { return; } this.IsFreeCamMode = !this.IsFreeCamMode; mainPlayer.SwitchFreeCamMode(); if (this.IsFreeCamMode) { Camera cam = this.mStateMgr.Camera; Vector3 position = cam.RealPosition; Quaternion orientation = cam.RealOrientation; cam.DetachFromParent(); cam.Position = position; cam.Orientation = orientation; this.mCameraMan = new CameraMan(cam); mainPlayer.SetIsAllowedToMove(false); } else { this.InitCamera(); mainPlayer.SetIsAllowedToMove(true); this.mCameraMan = null; } }
public ShootCube(BulletManager bulletManager, VanillaPlayer source) { this.mSource = source; this.mBulletMgr = bulletManager; this.mTimeSinceLastBall = new Timer(); this.mCamera = this.mBulletMgr.SceneMgr.GetCamera("Camera"); this.mMaterials = new string[] { "fireball", "waterball", "magicball" }; }
public void InitCamera() { VanillaPlayer mainPlayer = this.mStateMgr.MainState.CharacMgr.MainPlayer; if (mainPlayer != null) { mainPlayer.Node.SetVisible(false); } this.mCamYawNode = this.mStateMgr.MainState.CharacMgr.MainPlayer.Node.CreateChildSceneNode(); this.mCamYawNode.SetPosition(0, 3.6f, 0); // Camera is set at eyes level this.mCamYawNode.Yaw(new Degree(180)); this.mCamPitchNode = this.mCamYawNode.CreateChildSceneNode(); this.mCamPitchNode.AttachObject(this.mStateMgr.Camera); this.mStateMgr.Camera.Position = Vector3.ZERO; this.mStateMgr.Camera.Orientation = Quaternion.IDENTITY; }
public override void Update(float frameTime) { base.Update(frameTime); this.RTSManager.Update(frameTime); this.mBulletMgr.Update(frameTime); User user = this.mStateMgr.MainState.User; VanillaPlayer mainPlayer = this.mStateMgr.MainState.CharacMgr.MainPlayer; if (user.IsFreeCamMode && mainPlayer != null && !GUI.Visible) { bool ctrlPressed = this.mStateMgr.Controller.IsKeyDown(MOIS.KeyCode.KC_LCONTROL); mainPlayer.SetIsAllowedToMove(ctrlPressed, false); user.IsAllowedToMoveCam = !ctrlPressed; } if (this.mStateMgr.Controller.WasKeyPressed(MOIS.KeyCode.KC_F1) && !GUI.Visible) { user.SwitchFreeCamMode(); } }
public void Update(float frameTime) { MainState mainState = this.mStateMgr.MainState; VanillaPlayer mainPlayer = mainState.CharacMgr.MainPlayer; if (this.mIsMainGUIOpen && this.mTimeSinceGUIOpen.Milliseconds >= 3500 && this.mStateMgr.GameInfo.IsInEditorMode) { this.mIsMainGUIOpen = false; GUI.Visible = false; } if (this.mStateMgr.Controller.HasActionOccured(UserAction.Start)) { if (!GUI.Visible) { this.mStateMgr.MainState.OpenMainGUI(); this.SwitchGUIVisibility(true); this.mIsMainGUIOpen = true; this.mTimeSinceGUIOpen.Reset(); } else { if (this.mIsInventoryOpen) { this.SwitchInventory(false); this.mIsInventoryOpen = false; } else if (this.mIsBuilderOpen) { this.mIsBuilderOpen = false; if (this.BuildingMgr.HasActualBuilding() && !this.BuildingMgr.GetActualBuilding().Built) { this.BuildingMgr.GetActualBuilding().WaitForRessources(); } } else { this.mIsMainGUIOpen = false; /*if (this.mStateMgr.GameInfo.IsInEditorMode) * (this.mStateMgr.MainState as StoryEditorState).OnExit();*/ } this.SwitchGUIVisibility(false); GUI.Visible = false; } } if (RequestBuilderClose && this.mIsBuilderOpen) { RequestBuilderClose = false; this.mIsBuilderOpen = false; this.SwitchGUIVisibility(false); GUI.Visible = false; } if (!this.mStateMgr.Controller.IsActionOccuring(UserAction.MainAction)) { if (this.mStateMgr.Controller.HasActionOccured(UserAction.Inventory) && (!GUI.Visible || this.mIsInventoryOpen)) { this.mIsInventoryOpen = !this.mIsInventoryOpen; this.SwitchInventory(this.mIsInventoryOpen); this.SwitchGUIVisibility(this.mIsInventoryOpen); } } if (OpenBuilder) { Builder.OnOpen = this.OnBuilderOpen; new Builder(this.BuildingMgr); OpenBuilder = false; this.mIsBuilderOpen = true; this.SwitchGUIVisibility(true); } if (this.mStateMgr.Controller.HasActionOccured(UserAction.CreateUnit)) { this.PlayerRTS.CreateRobot(1); } if (this.mStateMgr.Controller.HasActionOccured(UserAction.SelectAll)) { this.mAreAllCharacSelected = !this.mAreAllCharacSelected; foreach (VanillaNonPlayer charac in this.mStateMgr.MainState.CharacMgr.GetFactionCharacters(Faction.Blue).OfType <VanillaNonPlayer>()) { if (!charac.IsFriendlySelected() && this.mAreAllCharacSelected) { this.mSelectedAllies.Add(charac); } else if (charac.IsFriendlySelected() && !this.mAreAllCharacSelected) { this.mSelectedAllies.Remove(charac); } charac.SetSelected(this.mAreAllCharacSelected); } } if (this.mStateMgr.Controller.HasActionOccured(UserAction.GoTo)) { int nbAllies = this.mSelectedAllies.Count; if (nbAllies <= 0) { return; } VanillaNonPlayer npc = this.GetSelectedNPC(); if (npc != null && npc.Info.Faction == Faction.Red) { foreach (VanillaNonPlayer ally in this.mSelectedAllies) { ally.SetTargetAndFollow(npc); } } else if (this.SelectedBlockPos != Vector3.ZERO) { int randomMax = (int)((nbAllies / 4f + 0.5f) * Cst.CUBE_SIDE); Vector3 imprecision = nbAllies == 1 ? Vector3.ZERO : new Vector3(this.mRandom.Next(0, randomMax), 0, this.mRandom.Next(0, randomMax)); foreach (VanillaNonPlayer ally in this.mSelectedAllies) { ally.MoveTo((this.SelectedBlockPos + new Vector3(0.5f, 1, -0.5f)) * Cst.CUBE_SIDE + imprecision); } } } if (this.mStateMgr.Controller.HasActionOccured(UserAction.FollowMe)) { foreach (VanillaNonPlayer ally in this.mSelectedAllies) { if (ally.IsFollowingCharac(mainPlayer)) { ally.StopFollowing(); } else { ally.Follow(mainPlayer, Cst.CUBE_SIDE * 2 + this.mRandom.Next(0, 100)); } } } /* Move camera */ if (this.IsAllowedToMoveCam) { bool secondaryActionHandled = false; if (this.IsFreeCamMode) { this.mCameraMan.UpdateCamera(frameTime, this.mStateMgr.Controller); } else if (mainPlayer.MovementInfo.IsAllowedToMove) // Just pitch the camera { this.mCamPitchNode.Pitch(new Degree(this.mStateMgr.Controller.Pitch)); if (2 * new Degree(Math.ACos(this.mCamPitchNode.Orientation.w)).ValueAngleUnits > 90.0f) // Limit the pitch between -90 degrees and +90 degrees { this.mCamPitchNode.SetOrientation(Math.Sqrt(0.5f), Math.Sqrt(0.5f) * Math.Sign(this.mCamPitchNode.Orientation.x), 0, 0); } if (this.mStateMgr.Controller.HasActionOccured(UserAction.SecondaryAction)) { secondaryActionHandled = this.UpdateSelectedNPC(); } } /* Cube addition and suppression */ float dist = this.UpdateSelectedBlock(); if (!(this.mStateMgr.GameInfo.IsInEditorMode ^ mainState.User.IsFreeCamMode) && this.SelectedBlock != null) // Allow world edition { if (this.mStateMgr.Controller.HasActionOccured(UserAction.MainAction) && !Selector.IsBullet && this.mWorld.onLeftClick(this.SelectedBlockPos)) { this.AddBlock(dist); } if (!secondaryActionHandled && this.mStateMgr.Controller.HasActionOccured(UserAction.SecondaryAction) && this.mWorld.onRightClick(this.SelectedBlockPos)) { this.DeleteBlock(); } } } /* Move Selector */ int selectorPos = Selector.SelectorPos; if (this.mStateMgr.Controller.HasActionOccured(UserAction.MoveSelectorLeft)) { selectorPos--; } if (this.mStateMgr.Controller.HasActionOccured(UserAction.MoveSelectorRight)) { selectorPos++; } for (int i = 0; i < this.mFigures.Length; i++) { if (this.mStateMgr.Controller.WasKeyPressed(this.mFigures[i])) { selectorPos = i; break; } } if (Selector.SelectorPos != selectorPos) { Selector.SelectorPos = selectorPos; } }