/////////////////////////////////////////////////////////// // various camera and weapon resets /////////////////////////////////////////////////////////// protected override void Reset() { base.Reset(); Player.AllowState("Zoom", true); Player.AllowState("Crouch", true); Player.ResetState(); Player.Camera.SetWeaponLayer(vp_Layer.Weapon); Player.Camera.SetWeapon(0); Player.Camera.StopEarthQuake(); Player.Camera.BobStepCallback = null; Player.Camera.SnapSprings(); if (Player.Camera.CurrentWeapon != null) { Player.Camera.CurrentWeapon.SetPivotVisible(false); Player.Camera.CurrentWeapon.SnapSprings(); } if (Screen.width < 1024) { EditorPreviewSectionExpanded = false; } else { EditorPreviewSectionExpanded = true; } if (m_UnFreezePosition != Vector3.zero) { UnFreezePlayer(); } }
/////////////////////////////////////////////////////////// // demo screen to show some example presets that are possible // with Ultimate FPS Camera /////////////////////////////////////////////////////////// private void DemoExamples() { Demo.DrawBoxes("examples", "Try MOVING, JUMPING and STRAFING with the demo presets on the left.\nNote that NO ANIMATIONS are used in this demo. Instead, the camera and weapons are manipulated using realtime SPRING PHYSICS, SINUS BOB and NOISE SHAKING.\nCombining this with traditional animations (e.g. reload) can be very powerful!", m_ImageLeftArrow, m_ImageRightArrow); if (Demo.FirstFrame) { Demo.DrawCrosshair = true; m_Player.Camera.SetWeapon(0); LoadCamera(SystemOFFCamera); m_Player.Controller.Load(SystemOFFController); Demo.Teleport(m_StartPos, m_StartAngle); // place the player at start point Demo.FirstFrame = false; m_UnFreezePosition = m_Player.Controller.transform.position; // makes player return to start pos when unfreezed (from sniper, turret presets etc.) Demo.ButtonSelection = 0; m_Player.SetWeaponAvailable(1, false); m_Player.SetWeaponAvailable(2, false); m_Player.SetWeaponAvailable(3, false); m_Player.SetWeaponAvailable(4, false); m_Player.SetWeaponAvailable(5, false); SwitchWeapon(3, SystemOFFWeaponGlideIn, SystemOFFShooter, 0, false, false); m_Player.Camera.SnapSprings(); Demo.RefreshDefaultState(); } // if selected button in toggle column has changed, change // the current preset if (Demo.ButtonSelection != m_ExamplesCurrentSel) { m_Player.ResetState(); m_Player.LockCursor = true; m_Player.Camera.SnapSprings(); m_Player.Camera.StopEarthQuake(); if (m_Player.Camera.CurrentWeapon != null) { m_Player.Camera.SnapSprings(); } m_Player.Camera.BobStepCallback = null; switch (Demo.ButtonSelection) { case 0: // --- System OFF --- Demo.DrawCrosshair = true; m_Player.Controller.Stop(); m_Player.Controller.Load(SystemOFFController); if (m_Player.Camera.CurrentWeaponID == 5) // mech cockpit is not allowed in 'system off' mode { LoadCamera(SystemOFFCamera); // so replace it by pistol SwitchWeapon(1, SystemOFFWeapon, SystemOFFShooter, 0, false, false); } else { LoadCamera(SystemOFFCamera); Demo.SetWeaponPreset(SystemOFFWeapon); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", false); } Demo.RefreshDefaultState(); break; case 1: // --- Mafia Boss --- Demo.DrawCrosshair = true; if (m_LastLoadedCamera == SystemOFFCamera) { LoadCamera(MafiaCamera); m_Player.Camera.SetWeapon(3); m_Player.AllowState("Zoom", true); m_Player.AllowState("Crouch", true); Demo.SetWeaponPreset(MafiaWeapon, MafiaShooter, true); } else { LoadCamera(MafiaCamera); SwitchWeapon(3, MafiaWeapon, MafiaShooter, -1, true, true); } m_Player.Controller.Load(ModernController); Demo.RefreshDefaultState(); break; case 2: // --- Modern Shooter --- Demo.DrawCrosshair = true; if (m_LastLoadedCamera == SystemOFFCamera) { LoadCamera(ModernCamera); m_Player.Camera.SetWeapon(1); m_Player.AllowState("Zoom", true); m_Player.AllowState("Crouch", true); Demo.SetWeaponPreset(ModernWeapon, ModernShooter, true); } else { LoadCamera(ModernCamera); SwitchWeapon(1, ModernWeapon, ModernShooter, -1, true, true); } m_Player.Controller.Load(ModernController); Demo.RefreshDefaultState(); break; case 3: // --- Barbarian --- Demo.DrawCrosshair = false; if (m_LastLoadedCamera == SystemOFFCamera) { LoadCamera(MaceCamera); m_Player.Camera.SetWeapon(4); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", true); Demo.SetWeaponPreset(MaceWeapon, null, true); } else { LoadCamera(MaceCamera); SwitchWeapon(4, MaceWeapon, null, -1, false, true); } m_Player.Controller.Load(ModernController); Demo.RefreshDefaultState(); break; case 4: // --- Sniper Breath --- Demo.DrawCrosshair = true; LoadCamera(SniperCamera); m_Player.Camera.SetWeapon(2); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", false); Demo.SetWeaponPreset(SniperWeapon, SniperShooter, true); m_Player.Controller.Stop(); m_Player.Controller.Load(CrouchController); Demo.Teleport(m_SniperPos, m_SniperAngle); Demo.RefreshDefaultState(); break; case 5: // --- Astronaut --- Demo.DrawCrosshair = false; LoadCamera(AstronautCamera); m_Player.Camera.SetWeapon(0); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", false); m_Player.Controller.Load(AstronautController); Demo.Teleport(m_AstronautPos, m_AstronautAngle); Demo.RefreshDefaultState(); break; case 6: // --- Mech... or Dino? --- Demo.DrawCrosshair = true; m_UnFreezePosition = m_DrunkPos; m_Player.Controller.Stop(); m_Player.Controller.Load(MechController); Demo.Teleport(m_MechPos, m_MechAngle); LoadCamera(MechCamera); m_Player.Camera.SetWeapon(5); m_Player.AllowState("Zoom", true); m_Player.AllowState("Crouch", false); Demo.SetWeaponPreset(MechWeapon, MechShooter, true); Demo.RefreshDefaultState(); m_Player.Camera.BobStepCallback = delegate() { m_Player.Camera.AddForce2(new Vector3(0.0f, -1.0f, 0.0f)); m_Player.Camera.CurrentWeapon.AddForce(new Vector3(0, 0, 0), new Vector3(-0.3f, 0, 0)); m_AudioSource.PlayOneShot(m_StompSound); }; break; case 7: // --- Tank Turret --- Demo.DrawCrosshair = true; LoadCamera(TurretCamera); m_Player.Camera.SetWeapon(3); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", false); Demo.SetWeaponPreset(TurretWeapon, TurretShooter, true); m_Player.Camera.CurrentWeapon.SnapSprings(); m_Player.Controller.Stop(); m_Player.Controller.Load(DefaultController); Demo.FreezePlayer(m_OverviewPos, m_OverviewAngle); Demo.RefreshDefaultState(); break; case 8: // --- Drunk Person --- Demo.DrawCrosshair = false; LoadCamera(DrunkCamera); m_Player.Camera.SetWeapon(0); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", true); m_Player.Controller.Stop(); m_Player.Controller.Load(DrunkController); Demo.Teleport(m_DrunkPos, m_DrunkAngle); Demo.RefreshDefaultState(); break; case 9: // --- Old School --- Demo.DrawCrosshair = true; LoadCamera(OldSchoolCamera); m_Player.Camera.SetWeapon(1); m_Player.AllowState("Zoom", false); m_Player.AllowState("Crouch", false); Demo.SetWeaponPreset(OldSchoolWeapon, OldSchoolShooter); m_Player.Controller.Stop(); m_Player.Controller.Load(OldSchoolController); Demo.Teleport(m_OldSchoolPos, m_OldSchoolAngle); m_Player.Camera.SnapSprings(); m_Player.Camera.SnapZoom(); m_Player.CurrentWeapon.SnapZoom(); m_Player.CurrentWeapon.SnapSprings(); m_Player.Camera.CurrentWeapon.SnapPivot(); Demo.RefreshDefaultState(); break; case 10: // --- Crazy Cowboy --- Demo.DrawCrosshair = true; if (m_LastLoadedCamera == SystemOFFCamera) { LoadCamera(CowboyCamera); m_Player.Camera.SetWeapon(2); m_Player.AllowState("Zoom", true); m_Player.AllowState("Crouch", true); Demo.SetWeaponPreset(CowboyWeapon, CowboyShooter, true); } else { LoadCamera(CowboyCamera); SwitchWeapon(2, CowboyWeapon, CowboyShooter, -1, true, true); } m_Player.Controller.Load(CowboyController); Demo.Teleport(m_StartPos, m_StartAngle); Demo.RefreshDefaultState(); break; } m_Player.SetState("Zoom", false); Demo.LastInputTime = Time.time; m_ExamplesCurrentSel = Demo.ButtonSelection; } if (m_Player.Camera.CurrentShooter != null) { if (Demo.ButtonSelection == 0) { m_Player.Camera.CurrentShooter.AmmoCount = 0; } else { m_Player.Camera.CurrentShooter.AmmoCount = 100000000; } } if (Demo.ShowGUI) { // show a toggle column, a compound control displaying a // column of buttons that can be toggled like radio buttons m_ExamplesCurrentSel = Demo.ButtonSelection; string[] strings = new string[] { "System OFF", "Mafia Boss", "Modern Shooter", "Barbarian", "Sniper Breath", "Astronaut", "Mech... or Dino?", "Tank Turret", "Drunk Person", "Old School", "Crazy Cowboy" }; Demo.ButtonSelection = Demo.ToggleColumn(140, 150, Demo.ButtonSelection, strings, false, true, m_ImageRightPointer, m_ImageLeftPointer); } // draw menu re-enable text if (Demo.ShowGUI && Screen.lockCursor) { GUI.color = new Color(1, 1, 1, 1); GUI.Label(new Rect((Screen.width / 2) - 200, 140, 400, 20), "(Press ENTER to reenable menu)", Demo.CenterStyle); GUI.color = new Color(1, 1, 1, 1 * Demo.GlobalAlpha); } }