private void SwitchTarget() { if (!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num2)) && redbot) { controllid = 1; } else if (!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num4)) && bluebot) { controllid = 2; } else if (!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num3)) && greenbot) { controllid = 3; } else { if ((!(KeyboardInputManager.IsPressed(Keyboard.Key.Space)) && (KeyboardInputManager.Downward(Keyboard.Key.Num1)))) { controllid = 0; } } }
private void SetUpKeyboard() { CreateCharacter(currPlayer); KeyboardInputManager kim = player.AddComponent <KeyboardInputManager>(); kim.CC = player.AddComponent <CharController>(); kim.CC.SetUp(); keyboardClaimed = true; player.AddComponent <PlayerInfo>().PlayerNumber = (currPlayer); pa.AddTarget(player.GetComponent <Transform>()); float r = Random.Range(0f, 1f); if (r < .33f) { kim.CC.SetRace(new R_Meat()); } else if (r < .67f) { kim.CC.SetRace(new R_Metal()); } else { kim.CC.SetRace(new R_Electronic()); } AssignUI(kim.CC, currPlayer); NextPlayer(); }
public void update(float deltaTime) { float speed = deltaTime; Vector2 inputMovement = new Vector2(0F, 0F); inputMovement.Y += KeyboardInputManager.IsPressed(Keyboard.Key.Down) ? speed : 0F; inputMovement.Y += KeyboardInputManager.IsPressed(Keyboard.Key.Up) ? -speed : 0F; inputMovement.X += KeyboardInputManager.IsPressed(Keyboard.Key.Left) ? -speed : 0F; inputMovement.X += KeyboardInputManager.IsPressed(Keyboard.Key.Right) ? speed : 0F; if (inputMovement.Y != 0F || inputMovement.X != 0F) { movement += inputMovement * speed / (float)Math.Sqrt(inputMovement.X * inputMovement.X + inputMovement.Y * inputMovement.Y); } movement *= (1F - deltaTime * 4F); // friction position += movement; if (position.X < 0) { position -= movement; movement *= Vector2.Up; } }
static void Main(string[] args) { // initialize window and view win = new RenderWindow(new VideoMode((uint)windowSize.X, (uint)windowSize.Y), "Hadoken!!!"); view = new View(); ResetView(); gui = new GUI(win, view); // prevent window resizing win.Resized += (sender, e) => { (sender as Window).Size = windowSize; }; // exit Program, when window is being closed //win.Closed += new EventHandler(closeWindow); win.Closed += (sender, e) => { (sender as Window).Close(); }; // initialize GameState HandleNewGameState(); // initialize GameTime GameTime = new GameTime(); GameTime.Start(); // debug Text Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf")); while (running && win.IsOpen()) { KeyboardInputManager.Update(); // update GameTime GameTime.Update(); float deltaTime = (float)GameTime.EllapsedTime.TotalSeconds; currentGameState = state.Update(deltaTime); if (currentGameState != prevGameState) { HandleNewGameState(); } // gather drawStuff from State win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337 state.Draw(win, view, deltaTime); state.DrawGUI(gui, deltaTime); // some DebugText debugText.DisplayedString = "fps: " + (1.0F / deltaTime); win.Draw(debugText); // do the actual drawing win.SetView(view); win.Display(); // check for window-events. e.g. window closed win.DispatchEvents(); Update_view(); } }
public GameState Update(float deltaTime) { if (KeyboardInputManager.IsPressed(Keyboard.Key.Return)) { return(GameState.InGame); } return(GameState.MainMenu); }
/// <summary> /// Checks for a click within the interaction framework v2. Until everything is moved over to V2, /// this will have to be used alongside the old one. /// </summary> private bool CheckClickV2() { //currently there is nothing for ghosts to interact with, they only can change facing if (PlayerManager.LocalPlayerScript.IsGhost) { return(false); } bool ctrlClick = KeyboardInputManager.IsControlPressed(); if (!ctrlClick) { var handApplyTargets = MouseUtils.GetOrderedObjectsUnderMouse(layerMask, go => go.GetComponent <RegisterTile>() != null) //get the root gameobject of the dropped-on sprite renderer .Select(sr => sr.GetComponentInParent <RegisterTile>().gameObject) //only want distinct game objects even if we hit multiple renderers on one object. .Distinct(); //object in hand var handObj = UIManager.Hands.CurrentSlot.Item; //go through the stack of objects and call any drop components we find foreach (GameObject applyTarget in handApplyTargets) { HandApply info = new HandApply(PlayerManager.LocalPlayer, handObj, applyTarget.gameObject); //call the used object's handapply interaction methods if it has any, for each object we are applying to //if handobj is null, then its an empty hand apply so we only need to check the receiving object if (handObj != null) { foreach (IInteractable <HandApply> handApply in handObj.GetComponents <IInteractable <HandApply> >()) { var result = handApply.Interact(info); if (result.SomethingHappened) { //we're done checking, something happened return(true); } } } //call the hand apply interaction methods on the target object if it has any foreach (IInteractable <HandApply> handApply in applyTarget.GetComponents <IInteractable <HandApply> >()) { var result = handApply.Interact(info); if (result.SomethingHappened) { //something happened, done checking return(true); } } } } return(false); }