void Update() { if (Managers.GameManager.State == Enums.GameStates.CardSelection) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { DrawPossibleSelections(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, thisPlayerIndex)) { Navigate(CustomInput.UserInput.Up); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, thisPlayerIndex)) { Navigate(CustomInput.UserInput.Down); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, thisPlayerIndex)) { Navigate(CustomInput.UserInput.Right); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, thisPlayerIndex)) { Navigate(CustomInput.UserInput.Left); } } }
private void Update() { if (Managers.GameState.Instance.IsPaused) { return; } this.Up = CustomInput.BoolHeld(CustomInput.UserInput.Up); this.Down = CustomInput.BoolHeld(CustomInput.UserInput.Down); this.Left = CustomInput.BoolHeld(CustomInput.UserInput.Left); this.Right = CustomInput.BoolHeld(CustomInput.UserInput.Right); this.anim.SetBool(this.upHash, this.Up); this.anim.SetBool(this.downHash, this.Down); this.anim.SetBool(this.leftHash, this.Left); this.anim.SetBool(this.rigthHash, this.Right); this.anim.SetBool(this.moveHash, this.Up || this.Down || this.Left || this.Right); if (behavior.CurrentState == Enums.HeroState.Attack && CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { this.behavior.AttackQueued = true; } this.anim.SetBool(this.attackHash, CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)); if (CustomInput.BoolFreshPress(CustomInput.UserInput.NextWeapon)) { this.behavior.GoToNextWeapon(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PrevWeapon)) { this.behavior.GoToPreviousWeapon(); } }
void Update() { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Up, packs[0].gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Down, packs[0].gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Right, packs[0].gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Left, packs[0].gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept, thisPlayerIndex)) { Navigator.CallSubmit(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Cancel, thisPlayerIndex)) { RemovePack(lastSelected); } }
void Update() { if (CustomInput.BoolFreshPress(CustomInput.UserInput.SelectCards)) { GameObject.Find("Card Selection Canvas").GetComponent <UI.CardSelector>().EnableCanvas(); } }
void Update() { if (Managers.GameManager.State == Enums.GameStates.CardSelection) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Up, okayButton.gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Down, okayButton.gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Right, okayButton.gameObject); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, thisPlayerIndex)) { Navigator.Navigate(CustomInput.UserInput.Left, okayButton.gameObject); } if (CustomInput.BoolFreshPressDeleteOnRead(CustomInput.UserInput.Accept, thisPlayerIndex)) { Navigator.CallSubmit(); } } }
/// <summary> Controls player movement. </summary> /// <param name="inAir"> Boolean for if the player is currently in the air. </param> private void Move(ref bool inAir) { if (CustomInput.BoolHeld(CustomInput.UserInput.Left)) { xVel = -moveSpeed; GetComponent <Animator>().SetBool("Walking", true); } else if (CustomInput.BoolHeld(CustomInput.UserInput.Right)) { xVel = moveSpeed; GetComponent <Animator>().SetBool("Walking", true); } else { xVel = 0; GetComponent <Animator>().SetBool("Walking", false); } if (!inAir && CustomInput.BoolFreshPress(CustomInput.UserInput.Jump)) { yVel = jumpSpeed; inAir = true; } if (Mathf.Abs(xVel) > maxRunSpeed) { if (xVel > 0) { xVel = maxRunSpeed; } else { xVel = -maxRunSpeed; } } transform.Translate(new Vector3(xVel * Time.deltaTime, yVel * Time.deltaTime, 0)); if (inAir) { if (yVel < maxFallSpeed) { yVel = maxFallSpeed; } else if (yVel > maxJumpSpeed) { yVel = maxJumpSpeed; } else { yVel -= gravity; } } else { yVel = 0; } }
void Update() { if (Managers.GameManager.State == Enums.GameStates.CardSelection) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { DrawPossibleSelections(); } } }
private void Update() { if (Managers.GameManager.Instance.IsPaused) { return; } if (this.player.IsDead) { this.anim.SetBool(this.aimHash, false); this.anim.SetBool(this.shootHash, false); return; } bool shouldAim = ShouldAim(); if (shouldAim) { this.aimDir = GetAimDir(); CalculateClipSet(Vector2.SignedAngle(Vector2.right, this.aimDir)); } bool shouldShoot = false; if (this.shotTimer > 0) { this.shotTimer -= Time.deltaTime; } if (CustomInput.BoolHeld(CustomInput.UserInput.Shoot1) || CustomInput.BoolHeld(CustomInput.UserInput.Shoot2)) { shouldShoot = true; } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Shoot1)) { if (this.prevBullet != null && this.prevBullet.gameObject.activeSelf) { this.prevBullet.Detonate(); this.prevBullet = null; this.shotTimer = this.spaceTime / 2f; } } this.anim.SetBool(this.aimHash, shouldAim); this.anim.SetBool(this.shootHash, shouldShoot); this.currentState = this.mapper.GetCurrentState(); switch (this.currentState) { case State.Idle: Idle(); break; case State.Aim: Aim(); break; case State.Shoot: Shoot(); break; } }
public void MoveButtons() { // TODO: function that lets me not have all this pointer switching stuff be hard coded twice. // to lazy to fix right now and don't think it'll matter. // Reassign all button references to proper place after navigation, then cards if applicable if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down) || this.isCredits && CustomInput.BoolFreshPress(CustomInput.UserInput.Left)) { GameObject temp = buttons[0]; for (int i = 1; i < buttons.Length; i++) { buttons[i - 1] = buttons[i]; } buttons[buttons.Length - 1] = temp; temp.transform.position = goalButtons[buttons.Length - 1].transform.position; if (cardParent) { GameObject tempCard = cards[0]; for (int i = 1; i < cards.Length; i++) { cards[i - 1] = cards[i]; cards[i - 1].transform.SetSiblingIndex(i - 1); } cards[cards.Length - 1] = tempCard; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up) || this.isCredits && CustomInput.BoolFreshPress(CustomInput.UserInput.Right)) { GameObject temp = buttons[buttons.Length - 1]; for (int i = buttons.Length - 2; i >= 0; i--) { buttons[i + 1] = buttons[i]; } buttons[0] = temp; temp.transform.position = goalButtons[0].transform.position; if (cardParent) { GameObject tempCard = cards[cards.Length - 1]; for (int i = cards.Length - 2; i >= 0; i--) { cards[i + 1] = cards[i]; cards[i + 1].transform.SetSiblingIndex(i + 1); } cards[0] = tempCard; } } // Play sound effect sp.PlaySong(1); }
// Update is called once per frame void Update() { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right)) { Navigate(CustomInput.UserInput.Right); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left)) { Navigate(CustomInput.UserInput.Left); } }
private void Update() { if (Managers.GameManager.Instance.IsPaused) { return; } this.anim.SetBool(this.move, (CustomInput.BoolHeld(CustomInput.UserInput.Left) || CustomInput.BoolHeld(CustomInput.UserInput.Right))); if (CustomInput.BoolFreshPress(CustomInput.UserInput.Jump)) { this.anim.SetTrigger(this.jump); jumpSound.Play(); } }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); return; } if ((CustomInput.BoolFreshPress(CustomInput.UserInput.Cancel) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) && Settings == null) { FindObjectOfType <UILevelSwitch>().BackToMenu(); } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Cancel) && (Settings.OnScreen && SettingsController.Settings.activeInHierarchy || LevelSelect1.OnScreen)) { GoToMainMenu(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept)) { navigateAccept(); } if ((MainMenu1.OnScreen || LevelSelect1.OnScreen) && EventSystem.current.currentSelectedGameObject != null) { CurrentDefault = EventSystem.current.currentSelectedGameObject; } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up)) { Navigator.Navigate(CustomInput.UserInput.Up, CurrentDefault); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down)) { Navigator.Navigate(CustomInput.UserInput.Down, CurrentDefault); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right)) { Navigator.Navigate(CustomInput.UserInput.Right, CurrentDefault); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left)) { Navigator.Navigate(CustomInput.UserInput.Left, CurrentDefault); } }
private static Enums.PlayerState BasicAttack(bool hit, bool animDone, Enums.Direction direction, Enums.CardTypes type, bool handEmpty) { if (hit) { return(Enums.PlayerState.Hit); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { hold = 0; } hold += UnityEngine.Time.deltaTime; if (hold > .5f) { hold = 0; return(Enums.PlayerState.Idle); } return(Enums.PlayerState.BasicAttack); }
void Update() { if (Managers.GameManager.State == Enums.GameStates.CardSelection) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { DrawPossibleSelections(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard0, thisPlayerIndex)) { SelectCard(0); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard1, thisPlayerIndex)) { SelectCard(1); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard2, thisPlayerIndex)) { SelectCard(2); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard3, thisPlayerIndex)) { SelectCard(3); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard4, thisPlayerIndex)) { SelectCard(4); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard5, thisPlayerIndex)) { SelectCard(5); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard6, thisPlayerIndex)) { SelectCard(6); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard7, thisPlayerIndex)) { SelectCard(7); } } }
public override void RunEntity() { if (hit) { if (invulerability <= 0) { currentHealth--; invulerability = invulerabilityTime; } hit = false; } if (invulerability > 0) { render = !render; Render(render); invulerability -= Time.deltaTime; } else if (!render) { render = true; Render(true); } //if (currentHealth < 0) // Die(); bool inAir = false, blocked = false; TouchingSomething(ref inAir, ref blocked); Move(ref inAir); Aim(); if (CustomInput.BoolFreshPress(CustomInput.UserInput.SwitchLeft)) { weapons.SwitchLeft(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.SwitchRight)) { weapons.SwitchRight(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { bulletManager.Shoot(weapons.GetWeapon(), barrel, transform.localScale.x < 0 ? Enums.Direction.Left : Enums.Direction.Right); } }
private Enums.PlayerState BasicAttack(bool hit, bool animDone, Enums.Direction direction, Enums.CardTypes type, bool handEmpty, int playerNumber) { if (hit) { return(Enums.PlayerState.Hit); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack, playerNumber)) { hold = 1; } if (animDone) { if (hold == 0) { return(Enums.PlayerState.Idle); } hold = 0; return(Enums.PlayerState.BasicAttack); } return(Enums.PlayerState.BasicAttack); }
//The following methods control when and how you can transition between states private static Enums.PlayerState Idle(bool hit, bool animDone, Enums.Direction direction, Enums.CardTypes type, bool handEmpty) { if (hit) { return(Enums.PlayerState.Hit); } if (!handEmpty && CustomInput.BoolFreshPress(CustomInput.UserInput.UseCard)) { //switch off of type return(Enums.PlayerState.Sword); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { return(Enums.PlayerState.BasicAttack); } if (direction != Enums.Direction.None) { return(Enums.PlayerState.MoveBegining); } return(Enums.PlayerState.Idle); }
/// <summary> Gets inputted actions from the player. </summary> /// <param name="actions">A set of action keys that the player has just pressed in the current frame.</param> protected virtual void GetInput(out HashSet <CustomInput.UserInput> actions) { this.Up = CustomInput.BoolHeld(CustomInput.UserInput.Up); this.Down = CustomInput.BoolHeld(CustomInput.UserInput.Down); this.Left = CustomInput.BoolHeld(CustomInput.UserInput.Left); this.Right = CustomInput.BoolHeld(CustomInput.UserInput.Right); actions = new HashSet <CustomInput.UserInput>(); CustomInput.UserInput[] actionEnums = { CustomInput.UserInput.Attack, CustomInput.UserInput.NextWeapon, CustomInput.UserInput.PrevWeapon, CustomInput.UserInput.Target }; foreach (CustomInput.UserInput action in actionEnums) { if (CustomInput.BoolFreshPress(action)) { actions.Add(action); } } }
private void Update() { if (Managers.GameState.Instance.IsPaused) { return; } this.Up = CustomInput.BoolHeld(CustomInput.UserInput.Up); this.Down = CustomInput.BoolHeld(CustomInput.UserInput.Down); this.Left = CustomInput.BoolHeld(CustomInput.UserInput.Left); this.Right = CustomInput.BoolHeld(CustomInput.UserInput.Right); this.anim.SetBool(this.moveHash, this.Up || this.Down || this.Left || this.Right); this.anim.SetBool(this.attackHash, CustomInput.BoolHeld(CustomInput.UserInput.Attack)); if (CustomInput.BoolFreshPress(CustomInput.UserInput.NextWeapon)) { this.behavior.GoToNextWeapon(); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PrevWeapon)) { this.behavior.GoToPreviousWeapon(); } }
public void Update() { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Cancel)) { if (hideBehaviour.OnScreen) { this.DismissDialog(); } } if (Keep.activeSelf && this.hideBehaviour.OnScreen) { Timer -= Time.deltaTime; if (Timer < 0.0f) { if (Go != null) { Go(); } this.DismissDialog(); } } }
void Update() { if (active && !finished && (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPress(CustomInput.UserInput.Melee) || CustomInput.BoolFreshPress(CustomInput.UserInput.Shoot) || CustomInput.BoolFreshPress(CustomInput.UserInput.Screech) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause))) { if (!skipIcon.enabled) { skipIcon.enabled = true; skipTimer = skipTimerMax; } else { Skip(); } } if (skipTimer > 0) { skipTimer -= Time.deltaTime; if (skipTimer <= 0) { skipIcon.enabled = false; } } }
void Update() { // Temp, remove later if (Input.GetKeyUp(KeyCode.Escape)) { Application.Quit(); } Attack(CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)); Up(CustomInput.BoolHeld(CustomInput.UserInput.Up)); //Checks if up is being held. Down(CustomInput.BoolHeld(CustomInput.UserInput.Down)); //Checks if down is being held. Jump(CustomInput.BoolFreshPress(CustomInput.UserInput.Jump)); anim.SetBool("Control", CustomInput.BoolFreshPress(CustomInput.UserInput.Control)); if (CustomInput.BoolHeld(CustomInput.UserInput.Left)) { Left(true); Right(false); Move(true); MoveSpeed(CustomInput.Raw(CustomInput.UserInput.Left)); } else if (CustomInput.BoolHeld(CustomInput.UserInput.Right)) { Left(false); Right(true); Move(true); MoveSpeed(CustomInput.Raw(CustomInput.UserInput.Right)); } else { Left(false); Right(false); Move(false); MoveSpeed(0f); } }
private static Enums.PlayerState InAir(bool inAir, bool move, bool hit, bool animDone) { if (hit) { return(Enums.PlayerState.Hit); } if (!inAir) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Jump)) { return(Enums.PlayerState.Jump); } if (move) { return(Enums.PlayerState.Moving); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack)) { return(Enums.PlayerState.Attack); } return(Enums.PlayerState.Idle); } return(Enums.PlayerState.InAir); }
void Update() { if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard0, thisPlayerIndex)) { AddPack(0); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard1, thisPlayerIndex)) { AddPack(1); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard2, thisPlayerIndex)) { AddPack(2); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard3, thisPlayerIndex)) { AddPack(3); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard4, thisPlayerIndex)) { AddPack(4); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard5, thisPlayerIndex)) { AddPack(5); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.PickCard6, thisPlayerIndex)) { AddPack(6); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Cancel, thisPlayerIndex)) { RemovePack(); } }
void Update() { if (Managers.GameManager.State == Enums.GameStates.Battle) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up)) { if (currentNode.panelAllowed(Enums.Direction.Up, Type)) { direction = Enums.Direction.Up; nextNode = currentNode.Up; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down)) { if (currentNode.panelAllowed(Enums.Direction.Down, Type)) { direction = Enums.Direction.Down; nextNode = currentNode.Down; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left)) { if (currentNode.panelAllowed(Enums.Direction.Left, Type)) { direction = Enums.Direction.Left; nextNode = currentNode.Left; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right)) { if (currentNode.panelAllowed(Enums.Direction.Right, Type)) { direction = Enums.Direction.Right; nextNode = currentNode.Right; } } else { direction = Enums.Direction.None; } //get next state currState = machine.update(hit, animDone, direction, hand.GetCurrentType(), hand.Empty()); //state clean up if (prevState != currState) { doOnce = false; animDone = false; hit = false; anim.SetInteger("state", (int)currState); } if (invunTimer > 0) { if (renderTimer > renderTime) { render = !render; renderTimer = 0; //GetComponent<Renderer>().enabled = render; } hit = false; renderTimer += Time.deltaTime; invunTimer -= Time.deltaTime; } else { //GetComponent<Renderer>().enabled = true; invun = false; } //run state doState[(int)currState](); if (move) { move = false; currentNode.clearOccupied(); currentNode = nextNode; currentNode.Owner = (this); transform.position = currentNode.transform.position; } if (useCard) { if (!hand.Empty()) { useCard = false; hand.UseCurrent(this); CardUIEvent(); } } if (basicAttack) { basicAttack = false; Weapons.Projectiles.Bullet b = Instantiate(bullet).GetComponent <Weapons.Projectiles.Bullet>(); b.transform.position = barrel.position; b.Direction = Direction; } if (damage > 0 && takeDamage) { takeDamage = false; TakeDamage(damage); damage = 0; } prevState = currState; } }
void Update() { if (Managers.GameManager.State == Enums.GameStates.Battle && !stun) { if (paused) { paused = false; anim.speed = animSpeed; } #region detectMove if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Up, Type)) { directionToMove = Enums.Direction.Up; nextNode = currentNode.Up; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Down, Type)) { directionToMove = Enums.Direction.Down; nextNode = currentNode.Down; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Left, Type)) { directionToMove = Enums.Direction.Left; nextNode = currentNode.Left; } } else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, playerNumber)) { if (currentNode.panelAllowed(Enums.Direction.Right, Type)) { directionToMove = Enums.Direction.Right; nextNode = currentNode.Right; } } else { directionToMove = Enums.Direction.None; } #endregion //get next state currState = machine.update(hit, animDone, directionToMove, hand.GetCurrentType(), hand.Empty(), playerNumber); //state clean up if (prevState != currState) { doOnce = false; animDone = false; attack = false; basicAttack = false; move = false; hit = false; if (weapon != null) { Destroy(weapon); } anim.SetInteger("state", (int)currState); } if (invunTimer > 0) { if (renderTimer > renderTime) { render = !render; renderTimer = 0; foreach (SkinnedMeshRenderer b in body) { b.enabled = render; } } hit = false; renderTimer += Time.deltaTime; invunTimer -= Time.deltaTime; } else if (!render || invun) { render = true; foreach (SkinnedMeshRenderer b in body) { b.enabled = true; } invun = false; } //run state switch (currState) { case Enums.PlayerState.Idle: Idle(); break; case Enums.PlayerState.MoveBegining: MoveBegining(); break; case Enums.PlayerState.MoveEnding: MoveEnding(); break; case Enums.PlayerState.Hit: Hit(); break; case Enums.PlayerState.Dead: Dead(); break; case Enums.PlayerState.BasicAttack: BasicAttack(); break; case Enums.PlayerState.HoriSwingMid: CardAnim(); break; case Enums.PlayerState.VertiSwingHeavy: CardAnim(); break; case Enums.PlayerState.ThrowLight: CardAnim(); break; case Enums.PlayerState.ThrowMid: CardAnim(); break; case Enums.PlayerState.Shoot: CardAnim(); break; case Enums.PlayerState.ChiAttack: CardAnim(); break; case Enums.PlayerState.ChiStationary: CardAnim(); break; case Enums.PlayerState.TauntGokuStretch: Taunt(); break; case Enums.PlayerState.TauntPointPoint: Taunt(); break; case Enums.PlayerState.TauntThumbsDown: Taunt(); break; case Enums.PlayerState.TauntWrasslemania: Taunt(); break; case Enums.PlayerState.TauntYaMoves: Taunt(); break; } if (move) { move = false; currentNode.clearOccupied(); currentNode = nextNode; currentNode.Owner = (this); transform.position = currentNode.transform.position; } #region useCard if (useCard) { if (!hand.Empty()) { Enums.CardTypes type = hand.GetCurrentType(); if (type == Enums.CardTypes.SwordHori || type == Enums.CardTypes.SwordVert) { weapon = Instantiate(Katana); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } if (type == Enums.CardTypes.WideSword) { weapon = Instantiate(WideSword); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.NaginataHori || type == Enums.CardTypes.NaginataVert) { weapon = Instantiate(Naginata); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.HammerHori || type == Enums.CardTypes.HammerVert) { weapon = Instantiate(Hammer); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.Fan) { weapon = Instantiate(Fan); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.Kanobo) { weapon = Instantiate(Kanobo); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale / .8f; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.Tanto) { weapon = Instantiate(Tanto); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.Wakizashi) { weapon = Instantiate(Wakizashi); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.Tonfa) { weapon = Instantiate(Tonfa); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale / .8f; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } else if (type == Enums.CardTypes.BoStaff) { weapon = Instantiate(BoStaff); weapon.transform.position = weaponPoint.position; weapon.transform.localScale = weaponPoint.localScale / .5f; weapon.transform.parent = weaponPoint; weapon.transform.localEulerAngles = new Vector3(0, 0, 0); } int sfxNumber = 0; switch (type) { case Enums.CardTypes.SwordVert: case Enums.CardTypes.SwordHori: case Enums.CardTypes.WideSword: case Enums.CardTypes.NaginataVert: case Enums.CardTypes.NaginataHori: case Enums.CardTypes.HammerVert: case Enums.CardTypes.HammerHori: case Enums.CardTypes.Fan: case Enums.CardTypes.Kanobo: case Enums.CardTypes.Tanto: case Enums.CardTypes.Wakizashi: case Enums.CardTypes.Tonfa: case Enums.CardTypes.BoStaff: sfxNumber = 0; break; case Enums.CardTypes.ThrowLight: case Enums.CardTypes.ThrowMid: case Enums.CardTypes.Shoot: sfxNumber = 2; break; case Enums.CardTypes.ChiAttack: case Enums.CardTypes.ChiStationary: sfxNumber = 3; break; default: break; } sfx.PlaySong(sfxNumber); useCard = false; hand.UseCurrent(this, deck); CardUIEvent(); } } #endregion if (basicAttack) { basicAttack = false; Weapons.Hitbox b = Instantiate(bullet); AddElement.AddElementByEnum(b.gameObject, element, true); b.Owner = this.gameObject; b.transform.position = Direction == Enums.Direction.Left ? currentNode.Left.transform.position : currentNode.Right.transform.position; b.CurrentNode = Direction == Enums.Direction.Left ? currentNode.Left : currentNode.Right; b.Direction = Direction; if (playerNumber == 2) { Transform model = b.transform.GetChild(0); model.localScale = new Vector3(model.localScale.x, -model.localScale.y, model.localScale.z); } sfx.PlaySong(2); } if (damage > 0 && takeDamage) { takeDamage = false; TakeDamage(damage, damageElement); damage = 0; damageElement = Enums.Element.None; } prevState = currState; } else { if (!paused) { animSpeed = anim.speed; anim.speed = 0; paused = true; } if (stun) { if ((stunTimer += Time.deltaTime) > stunTime) { stunTimer = 0f; stun = false; } } } }
private void Update() { if (Managers.GameState.Instance.CurrentState != Managers.GameState.State.Playing) { return; } if (invunTimer > 0) { if (flashTimer > flashInterval) { isVisible = !isVisible; flashTimer = 0; this.mesh.SetActive(isVisible); } flashTimer += Time.deltaTime; invunTimer -= Time.deltaTime; } else if (!isVisible || isInvulnerable) { isVisible = true; this.mesh.SetActive(true); isInvulnerable = false; } if (this.Health <= 0 && !this.dead) { GameOver.Instance.Show(); this.sfx.PlayPlayerDieSFX(); this.dead = true; } float yRot = cameraControl.UpdateCamera(); if (yRot != 0) { float z = this.transform.rotation.eulerAngles.z; this.transform.Rotate(new Vector3(0f, yRot, 0f)); this.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, z); } if (this.Moving) { Move(); } this.anim.SetBool(this.moveHash, this.Moving); if (!this.meleeing && CustomInput.BoolFreshPress(CustomInput.UserInput.Melee)) { this.meleeCollider.enabled = true; this.meleeing = true; CaneHitbox.enabled = true; this.anim.SetBool(this.meleeHash, true); this.sfx.PlayPlayerMeleeSFX(); } else if (this.meleeing) { this.rgdb.velocity *= .5f; } if (!reloading && !shooting && CustomInput.BoolFreshPress(CustomInput.UserInput.Shoot)) { GameObject g = BulletPool.Instance.GetBullet(BulletPool.BulletTypes.Player); if (g != null) { this.shooting = true; ObjectPooling.Bullets.Bullet rf = g.GetComponent <ObjectPooling.Bullets.Bullet>(); MeleeWeaponTrail[] fb = rf.trails; if (fb != null) { foreach (MeleeWeaponTrail m in fb) { m.startTrail(); } } g.transform.position = gunPos.position; g.transform.rotation = gunPos.rotation; this.anim.SetBool(this.shootHash, true); this.agro.radius += 1f; this.sfx.PlayPlayerGunfireSFX(); this.reloadUI.Fire(this.bullets); this.bullets--; } } else if (this.shooting) { this.rgdb.velocity *= .75f; } if (!reloading && (bullets < 0 || CustomInput.BoolFreshPress(CustomInput.UserInput.Reload))) { this.reloading = true; this.reloadUI.StartReload(); } else if (this.reloading && !this.reloadUI.IsReloading) { this.bullets = this.maxBullets; this.reloading = false; } if (!this.recharging && CustomInput.BoolFreshPress(CustomInput.UserInput.Screech)) { this.recharging = true; this.agro.radius *= 2f; this.screechUI.StartRecharge(); this.camEffects.Screech(); GameObject s = SonarPool.Instance.GetSonar(1f, 10f); s.transform.position = this.foot.position; s = SonarPool.Instance.GetSonar(8f, 10f); s.transform.position = this.foot.position; this.sfx.PlayPlayerSonarSFX(); } else if (this.recharging && !this.screechUI.IsRecharging) { this.recharging = false; } this.agro.radius = Mathf.Min(this.agro.radius, this.agroCap); if (this.agro.radius > this.originalRadius) { this.agro.radius -= Time.deltaTime * .75f; } }
void Update() { if (state != State.waiting) { image.sprite = backgrounds[whichBackgroundForWhichPage[currentPage]]; text.text = currentText.ToString(); } if (state == State.waiting) { if (start) { GameState.Instance.State = Enums.GameState.Cutscene; state = State.displaying; pageChars = pageStrings[currentPage].ToCharArray(); canvas.SetActive(true); } } else if (state == State.displaying) { if (Util.CustomInput.BoolFreshPress(Util.CustomInput.UserInput.Pause)) { for (int i = Mathf.RoundToInt(currentLetter); i < pageChars.Length; i++) { currentText.Append(pageChars[i]); } state = State.paused; } else { if (currentLetter == 0) { currentText.Append(pageChars[(int)currentLetter]); } int a = (int)(currentLetter); float temp = textSpeed; if (Util.CustomInput.BoolHeld(Util.CustomInput.UserInput.Accept) || Util.CustomInput.BoolHeld(Util.CustomInput.UserInput.Attack)) { temp *= 2; } currentLetter += temp * Time.deltaTime; if (a < (int)currentLetter && currentLetter < pageChars.Length) { currentText.Append(pageChars[(int)currentLetter]); sound.PlaySong(0); } if (currentLetter >= pageChars.Length) { //currentText = new System.Text.StringBuilder(pageStrings[currentPage]); state = State.paused; } } } else { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPress(CustomInput.UserInput.Attack) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) { currentLetter = 0; currentPage++; if (currentPage >= pages.Length) { text.text = ""; GameState.Instance.State = Enums.GameState.Playing; canvas.SetActive(false); Destroy(this.gameObject); } else { pageChars = pageStrings[currentPage].ToCharArray(); currentText = new System.Text.StringBuilder(); state = State.displaying; } } } }
//The following methods control when and how you can transition between states private Enums.PlayerState Idle(bool hit, bool animDone, Enums.Direction direction, Enums.CardTypes type, bool handEmpty, int playerNumber) { if (hit) { return(Enums.PlayerState.Hit); } if (!handEmpty && CustomInput.BoolFreshPress(CustomInput.UserInput.UseCard, playerNumber)) { switch (type) { case Enums.CardTypes.SwordVert: return(Enums.PlayerState.VertiSwingHeavy); case Enums.CardTypes.SwordHori: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.WideSword: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.NaginataVert: return(Enums.PlayerState.VertiSwingHeavy); case Enums.CardTypes.NaginataHori: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.HammerVert: return(Enums.PlayerState.VertiSwingHeavy); case Enums.CardTypes.HammerHori: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.ThrowLight: return(Enums.PlayerState.ThrowLight); case Enums.CardTypes.ThrowMid: return(Enums.PlayerState.ThrowMid); case Enums.CardTypes.Shoot: return(Enums.PlayerState.Shoot); case Enums.CardTypes.ChiAttack: return(Enums.PlayerState.ChiAttack); case Enums.CardTypes.ChiStationary: return(Enums.PlayerState.ChiStationary); case Enums.CardTypes.Error: return(Enums.PlayerState.ChiAttack); case Enums.CardTypes.Fan: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Kanobo: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Tanto: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Wakizashi: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.Tonfa: return(Enums.PlayerState.HoriSwingMid); case Enums.CardTypes.BoStaff: return(Enums.PlayerState.HoriSwingMid); } } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Attack, playerNumber)) { return(Enums.PlayerState.BasicAttack); } if (direction != Enums.Direction.None) { return(Enums.PlayerState.MoveBegining); } if (CustomInput.BoolFreshPress(CustomInput.UserInput.Taunt, playerNumber)) { float chance = UnityEngine.Random.Range(0f, 1f); if (chance < .225f) { return(Enums.PlayerState.TauntPointPoint); } else if (chance < .45f) { return(Enums.PlayerState.TauntThumbsDown); } else if (chance < .675f) { return(Enums.PlayerState.TauntWrasslemania); } else if (chance < .9f) { return(Enums.PlayerState.TauntYaMoves); } else { return(Enums.PlayerState.TauntGokuStretch); } } return(Enums.PlayerState.Idle); }
void Update() { if (!start) { if (GameState.Instance.IsPaused && GameState.Instance.State != Enums.GameState.Cutscene) { return; } else if (!this.doOnce) { GameState.Instance.State = Enums.GameState.Cutscene; DungeonManager.GetHero().SetActive(false); for (int i = 0; i < this.actors.Length; i++) { if (this.actorEntrancePage[i] == 0) { this.actors[i].StartTranslate(true); } } this.doOnce = true; } } if (this.waitingToExit) { bool allDone = true; foreach (Effects.Translate actor in this.actors) { if (!actor.Finished) { allDone = false; } } if (allDone) { GameState.Instance.State = Enums.GameState.Playing; DungeonManager.GetHero().SetActive(true); DungeonManager.TransitionMaps(); } } if (this.state != State.waiting && !this.waitingToExit) { this.image.sprite = this.backgrounds[this.whichBackgroundForWhichPage[currentPage]]; this.text.text = this.currentText.ToString(); } if (this.state == State.waiting) { if (start) { this.state = State.displaying; this.pageChars = this.pageStrings[this.currentPage].ToCharArray(); this.canvas.SetActive(true); } else { bool allDone = true; foreach (Effects.Translate actor in this.actors) { if (!actor.Finished) { allDone = false; } } if (allDone) { start = true; } } } else if (this.state == State.displaying) { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) { this.currentText = new System.Text.StringBuilder(this.pageStrings[this.currentPage]); this.state = State.paused; } else { if (this.currentLetter == 0) { this.currentText.Append(this.pageChars[(int)currentLetter]); } int a = (int)(currentLetter); float temp = this.textSpeed; if (CustomInput.BoolHeld(CustomInput.UserInput.Accept) || CustomInput.BoolHeld(CustomInput.UserInput.Attack)) { temp *= 2; } this.currentLetter += temp * Time.deltaTime; if (a < (int)this.currentLetter && this.currentLetter < this.pageChars.Length) { this.currentText.Append(this.pageChars[(int)this.currentLetter]); this.sound.PlaySong(0); } if (this.currentLetter >= this.pageChars.Length) { //currentText = new System.Text.StringBuilder(pageStrings[currentPage]); this.state = State.paused; } } } else { if (CustomInput.BoolFreshPress(CustomInput.UserInput.Accept) || CustomInput.BoolFreshPress(CustomInput.UserInput.Attack) || CustomInput.BoolFreshPress(CustomInput.UserInput.Pause)) { this.currentLetter = 0; this.currentPage++; for (int i = 0; i < this.actors.Length; i++) { if (this.actorEntrancePage[i] == this.currentPage) { this.actors[i].StartTranslate(true); } } for (int i = 0; i < this.actors.Length; i++) { if (this.actorExitPage[i] == this.currentPage) { this.actors[i].transform.localScale = new Vector3( -this.actors[i].transform.localScale.x, this.actors[i].transform.localScale.y, this.actors[i].transform.localScale.z); this.actors[i].StartTranslate(false); } } if (this.currentPage >= this.pages.Length) { this.text.text = ""; this.canvas.SetActive(false); this.waitingToExit = true; this.start = false; this.state = State.waiting; } else { this.pageChars = this.pageStrings[this.currentPage].ToCharArray(); this.currentText = new System.Text.StringBuilder(); this.state = State.displaying; } } } }