public IEnumerator moveToTileCor(Tile dest, action actionFinished) { Vector3 singleAxisPosition = transform.position; singleAxisPosition.x = dest.transform.position.x; move.Invoke(this); //unlinks old tile from this unit dest.setUnit(this); if (sprite) { sprite.SetAnimation("move"); } yield return(moveToPositionEnum(singleAxisPosition, moveSpeed, false)); yield return(moveToPositionEnum(dest.transform.position, moveSpeed, false)); if (sprite) { sprite.SetAnimation("idle"); } move += dest.unsetUnit; if (actionFinished != null) { actionFinished.Invoke(); } }
public virtual void interact(MouseState mouseState, MouseState pastMouseState) { if (visible) { if (rectangle.Contains(mouseState.X, mouseState.Y)) { if (hovered == false) { buttonSoundEffects[0].Play(); hovered = true; } if (mouseState.LeftButton == ButtonState.Released && pastMouseState.LeftButton == ButtonState.Pressed) { //Button has been pressed. Invoke clickAction buttonSoundEffects[1].Play(); clickAction.Invoke(); } } else { hovered = false; } } else { hovered = false; } }
public void SetAction(GameObject[,] buttons, action act) { foreach (GameObject but in buttons) { but.GetComponent <Button>().onClick.AddListener(delegate { act.Invoke(but); }); } }
void keyboardMgnt(KeyboardState kbState, GameTime gameTime) { Keys[] KeyPressed = kbState.GetPressedKeys(); if (KeyPressed.Contains(Keys.Left)) { mainChar.setAction(Character.walk.LEFT); } else if (KeyPressed.Contains(Keys.Right)) { mainChar.setAction(Character.walk.RIGHT); } else if (KeyPressed.Contains(Keys.Up)) { mainChar.setAction(Character.walk.UP); } else if (KeyPressed.Contains(Keys.Down)) { mainChar.setAction(Character.walk.DOWN); } else { mainChar.setAction(Character.walk.NOP); } if (!KeyPressed.Contains(Keys.Escape)) { if (OldKeyPressed.Contains(Keys.Escape)) { _game.ChangeState(ConstVar.menu); } } if (!KeyPressed.Contains(Keys.Space)) { if (OldKeyPressed.Contains(Keys.Space) && ban.isVisible) { ban.isVisible = false; ban.isActive = false; mainChar.move = false; effectOpenWindow.Play(); ConstVar.chooseBucket.window.widget = ConstVar.main.mainChar.Inventory; _game.ChangeState(ConstVar.chooseBucket); } if (OldKeyPressed.Contains(Keys.Space)) { space_button_action?.Invoke(); } } OldKeyPressed = KeyPressed; }
public IEnumerator checkHealth(action actionFinished) { yield return(new WaitForSeconds(0.5f)); if (health <= 0) { move.Invoke(this); //unlinks old tile from this unit death.Invoke(this); } if (actionFinished != null) { actionFinished.Invoke(); actionFinished = null; } }
private void OnCollisionEnter2D(Collision2D collision) { die.Invoke(); }
public void SetAction(GameObject button, action act, int index) { button.GetComponent <Button>().onClick.AddListener(delegate { act.Invoke(index); }); }
public void SetAction(GameObject button, action act, ControlStatesScript newState) { button.GetComponent <Button>().onClick.AddListener(delegate { act.Invoke(newState); }); }
public void SetAction(GameObject button, int players, action act) { button.GetComponent <Button>().onClick.AddListener(delegate { act.Invoke(players); }); }