public void Update(Vector3 target) { if (!isCameraControllable || isSoftLocked) { if (targetObject == null) { cameraTarget = target; } else { cameraTarget = targetObject.Position; } } //Camera update for top-down view //cameraPosition = new Vector3((cameraTarget.X ), (cameraTarget.Y + (5 + (5 * currentZoom))), (cameraTarget.Z)); //cameraViewMatrix = Matrix.CreateLookAt(cameraPosition, cameraTarget, new Vector3(1, 0, 0)); // cameraPosition =cameraRotation+ new Vector3((cameraTarget.X - (5 * currentZoom)), (cameraTarget.Y + (5 + (5 * currentZoom))), (cameraTarget.Z - (5 * currentZoom))); // cameraPosition = cameraRotation + cameraPosition; DebugScreen.GetInstance().SetDebugListing("Camera Rotation:", "" + rotationRadians); Matrix rotationMatrix = Matrix.CreateRotationY(-rotationRadians); cameraOffset = new Vector3(5 * currentZoom, 5 * currentZoom, 0); Vector3 transformedReference = Vector3.Transform(cameraOffset, rotationMatrix); cameraPosition = transformedReference + cameraTarget; cameraViewMatrix = Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.Up); // cameraPosition = new Vector3((cameraTarget.X - (5 * currentZoom)), (cameraTarget.Y + (5 + (5 * currentZoom))), (cameraTarget.Z - (5 * currentZoom))); //cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), graphics.Viewport.AspectRatio, 1.0f, 10000.0f); }
private void Start() { animatorControl = GetComponent <PlayerAnimator>(); verticalSpeed = minFall; character = GetComponent <CharacterController>(); screen = DebugScreen.GetInstance(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); /* spriteBatch.Begin(SpriteSortMode.Immediate, * BlendState.NonPremultiplied, * SamplerState.LinearClamp, * DepthStencilState.Default, * RasterizerState.CullCounterClockwise, * null, Matrix.Identity);*/ //NOTE: Should create and loop through tempScreenList here in case a screen is added or removed while drawing foreach (AbstractScreen screen in screens) { if (screen.IsVisible) { screen.Draw(spriteBatch); } } if (DebugScreen.GetInstance().IsVisible) { DebugScreen.GetInstance().Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }
void Start() { if (instance != null) { Destroy(this); } else { instance = this; debugScreen = GameObject.Find("Debug Screen"); world = GameObject.Find("World").GetComponent <World>(); screen = DebugScreen.GetInstance(); player = GameObject.Find("Player"); settingMenu = GetComponent <SettingMenu>(); if (MainScene == SceneManager.GetActiveScene().buildIndex) { inputController = PlayerInputController.GetInstance(); } else { inputController = EditInputController.GetInstance(); } WorldInit(); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { // Allows the game to exit /* if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) * this.Exit();*/ if (DebugScreen.GetInstance().IsActive) { DebugScreen.GetInstance().HandleInput(gameTime, input); DebugScreen.GetInstance().Update(gameTime); } input.Update(this.Game.IsMouseVisible); tempScreensList.Clear(); foreach (AbstractScreen screen in screens) { tempScreensList.Add(screen); } foreach (AbstractScreen screen in tempScreensList) { if (screen.HasFocus) { screen.HandleInput(gameTime, input); } if (screen.IsActive) { screen.Update(gameTime); } } //Any controls that are accessible to all screens will go here (i.e. toggle fullscreen) if (input.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F3) && !input.PreviousKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F3)) { DebugScreen.GetInstance().IsVisible = !DebugScreen.GetInstance().IsVisible; } /* if (input.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back)) * { * ToggleFullscreen(); * //graphics.ToggleFullScreen(); * }*/ base.Update(gameTime); }
void Start() { camTrans = transform.Find("Main Camera"); screen = DebugScreen.GetInstance(); world = GameObject.Find("World").GetComponent <World>(); promptText = GameObject.Find("Selection prompt").GetComponent <Text>(); //设置Enermy默认模型 enermyModelPrefab = PrefabManager.GetInstance().GetPrefab(PrefabType.Breaker); InitMonsterModel(); }
public void Render(GraphicsDevice graphicsDevice) { graphicsDevice.SetVertexBuffer(VertexBuffer); graphicsDevice.Indices = IndexBuffer; DebugScreen.GetInstance().PolysDrawn += Indices.Length / 3; DebugScreen.GetInstance().VertsDrawn += Vertices.Length; if (Vertices.Length > 0) { graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, Vertices.Length, 0, Indices.Length / 3); } }
// Use this for initialization void Start() { enemiesParent = GameObject.Find("Enemies"); enemyTypeList = new List <int>(); hordeWave = new List <int>(); enemyList = new List <GameObject>(); Enemy.Death += EnemyKilled; if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("Kill All Enemies", KillAllEnemies); DebugScreen.GetInstance().AddButton("NextWave", NextWave); } chanceOfHardRound = initialChanceOfHardRound; timerWaves = timeBetweenWaves; aSource = GetComponent <AudioSource>(); AudioManager.Get().AddSound(aSource); }
private void Initialize() { loader = LoaderManager.Get(); Tower.TowerDestroyed += GameOver; LightStand.LightFinished += GameWon; if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("ResetGameScene", ResetGame); DebugScreen.GetInstance().AddButton("Add Players Level", LevelUpPlayers); } aSource = GetComponent <AudioSource>(); AudioManager.Get().AddMusic(aSource); mage = GameObject.Find("Mage"); archer = GameObject.Find("Archer"); GiveOrbsToPlayers(); isInitialized = true; }
private void Start() { healthAnimator = healthBar.GetComponent <Animator>(); if (healthText) { if (health <= 0) { health = 0; } healthText.text = (health * 100 / maxHealth).ToString() + " %"; } if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("DestroyTower", DestroyTower); DebugScreen.GetInstance().AddButton("TowerInvulnerable", TowerInvulnerable); DebugScreen.GetInstance().AddButton("RepairTower", RepairTower); DebugScreen.GetInstance().AddButton("RepairRamparts", RepairRamparts); } }
private void Start() { if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("Win", CompleteLight); } LightUICanvas.maxLightValue = maxLight; playerList = new List <GameObject>(); particles = GetComponentInChildren <ParticleSystem>(); em = particles.emission; lightAnimator = GetComponent <Animator>(); if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("Activate Ultimate", DebugSetUltimateAvailable); } lightStones = new List <GameObject>(); for (int i = 1; i <= lightStonesCount; i++) { lightStones.Add(transform.Find("LightStand").transform.Find("L" + i).gameObject); } promptButton = transform.Find("Canvas").Find("PromptButton").gameObject; }
private ScreenManager(Game game) : base(game) { buttonIcons[0] = "Images\\Menus\\Menu Elements\\SimulatorIdleButton"; buttonIcons[1] = "Images\\Menus\\Menu Elements\\SimulatorHoverButton"; buttonIcons[2] = "Images\\Menus\\Menu Elements\\SimulatorHoverButton"; //graphics = new GraphicsDeviceManager(this); //Content.RootDirectory = "Content"; content = Game.Content; graphics = new GraphicsDeviceManager(game); //Set up the window as a borderless form Application.EnableVisualStyles(); gameForm = (Form)Form.FromHandle(game.Window.Handle); ToggleFullscreen(); /* gameForm.FormBorderStyle = FormBorderStyle.None; * gameForm.Left = 0; * gameForm.Top = 0; */ //Form MyGameForm = (Form)Form.FromHandle(game.Window.Handle); // MyGameForm.FormBorderStyle = FormBorderStyle.None; // graphics.PreferredBackBufferWidth = GraphicsDevice.Viewport.Width;//1280; // graphics.PreferredBackBufferHeight = GraphicsDevice.Viewport.Height;//720; // graphics.PreferredBackBufferWidth = 1920; //GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;//1280; // graphics.PreferredBackBufferHeight = 1080;// GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;//720; //NOTE: Multisampling and Fullscreen toggle do not work graphics.PreferMultiSampling = true; // graphics.IsFullScreen = isFullscreen; graphics.ApplyChanges(); game.Exiting += GameExiting; DebugScreen.GetInstance(); }
void Start() { animator = GetComponent <Animator>(); screen = DebugScreen.GetInstance(); }
public void HandleInput(InputState input) { Temp_updateCount++; ButtonState currentMouseState = new ButtonState(); ButtonState previousMouseState = new ButtonState();; if (input.CurrentMouseState.MiddleButton == ButtonState.Pressed) { currentMouseState = input.CurrentMouseState.MiddleButton; previousMouseState = input.PreviousMouseState.MiddleButton; } else if (input.CurrentMouseState.RightButton == ButtonState.Pressed) { currentMouseState = input.CurrentMouseState.RightButton; previousMouseState = input.PreviousMouseState.RightButton; } if (currentMouseState == ButtonState.Pressed) { ScreenManager.GetInstance().Game.IsMouseVisible = false; //Only record position on click if (previousMouseState == ButtonState.Released) { TEMP_mouseClickPosition = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y); } TEMP_mouseDelta = input.CurrentMouseState.X - TEMP_mouseClickPosition.X; DebugScreen.GetInstance().SetDebugListing("Mouse Delta:", "" + TEMP_mouseDelta); RotateCamera(TEMP_mouseDelta); if (input.CurrentMouseState.RightButton == ButtonState.Pressed) { if (targetObject != null && targetObject is TEMPPlayerActor) { (targetObject as TEMPPlayerActor).Rotation = new Vector3((targetObject as TEMPPlayerActor).Rotation.X, -rotationRadians, (targetObject as TEMPPlayerActor).Rotation.Z); } } //NOTE: Resetting this position is causing camera rotation to be jerky //Don't reset every tick //TEMPORARY SOLUTION - need proper way to make mouse rotation smooth if (Temp_updateCount % 5 == 0) { Mouse.SetPosition((int)TEMP_mouseClickPosition.X, (int)TEMP_mouseClickPosition.Y); } } else { ScreenManager.GetInstance().Game.IsMouseVisible = true; } bool trackingObject = false; if (targetObject != null) { /* if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || isSoftLocked) * { * trackingObject = true; * }*/ } else { trackingObject = true; } if (trackingObject) { Vector3 positiveCameraDirection = cameraTarget - CameraPosition; Vector3 cameraMove = Vector3.Zero; isCameraControllable = true; //if (input.CurrentKeyboardState.IsKeyDown(Keys.W)) //{ // cameraMove.X -= cameraMoveSpeed; // if (isSoftLocked) // { // targetObject = null; // isSoftLocked = false; // } //} //if (input.CurrentKeyboardState.IsKeyDown(Keys.D)) //{ // cameraMove.Z -= cameraMoveSpeed; // if (isSoftLocked) // { // targetObject = null; // isSoftLocked = false; // } //} //if (input.CurrentKeyboardState.IsKeyDown(Keys.S)) //{ // cameraMove.X += cameraMoveSpeed; // if (isSoftLocked) // { // targetObject = null; // isSoftLocked = false; // } //} //if (input.CurrentKeyboardState.IsKeyDown(Keys.A)) //{ // cameraMove.Z += cameraMoveSpeed; // if (isSoftLocked) // { // targetObject = null; // isSoftLocked = false; // } //} //if (input.CurrentKeyboardState.IsKeyDown(Keys.Space)/* && input.PreviousKeyboardState.IsKeyUp(Keys.Space)*/) //{ // if (TEMP_velJump == 0) // { // TEMP_velJump = 0.5f; // } //} //cameraTarget.Y += TEMP_velJump; //TEMP_velJump -= (9.8f / 200); //if (cameraTarget.Y < 0) //{ // cameraTarget.Y = 0; // TEMP_velJump = 0; //} //Matrix rotationMatrix = Matrix.CreateRotationY(-rotationRadians); //Vector3 transformedReference = Vector3.Transform(cameraMove, rotationMatrix); //cameraTarget += transformedReference; } else { isCameraControllable = false; } float scrollWheelChange = 0; if (input != null) { scrollWheelChange = input.PreviousMouseState.ScrollWheelValue - input.CurrentMouseState.ScrollWheelValue; } if (scrollWheelChange < 0 || (input.CurrentKeyboardState.IsKeyDown(Keys.Add) && input.PreviousKeyboardState.IsKeyUp(Keys.Add))) { ZoomCameraIn(); } else if (scrollWheelChange > 0 || (input.CurrentKeyboardState.IsKeyDown(Keys.Subtract) && input.PreviousKeyboardState.IsKeyUp(Keys.Subtract))) { ZoomCameraOut(); } if (Temp_updateCount % 60 == 0) { Temp_updateCount = 0; } }
/* * Finished * 对pos设置类型为type的方块 */ public void SetCube(Vector3 pos, CubeType type) { DebugScreen.GetInstance().Log("World", pos.ToString()); cubeManager.SetCube(pos, type); }