public bool IsValidInput(int playerIndex, Note.Button but, InputManager.InputType type) { Player targetPlayer = Player[playerIndex]; if (playerIndex == AttackerIndex) { AttackSkill skill = targetPlayer.GetAttackSkill(but); // skill is not long button -> ignore long button input if (!skill.IsLongButton && (type == InputManager.InputType.KEEP || type == InputManager.InputType.UP)) { return(false); } // UP or KEEP signal came without DOWN signal -> ignore input if (LastButton != but && (type == InputManager.InputType.KEEP || type == InputManager.InputType.UP)) { return(false); } return(true); } else { // ignore long button input if (type == InputManager.InputType.KEEP || type == InputManager.InputType.UP) { return(false); } return(true); } }
public void DoBattle(uint id, int time) { // assign basic variables Player attacker = (this.AttackerIndex == 0) ? Player[0] : Player[1]; Player defender = (this.AttackerIndex == 0) ? Player[1] : Player[0]; Note.Core attackData = (this.AttackerIndex == 0) ? GetData(0, id) : GetData(1, id); Note.Core defendData = (this.AttackerIndex == 0) ? GetData(1, id) : GetData(0, id); // show miss layer if (attackData.Judge < 50) { JudgeAnim[0].Play("miss", -1, 0); } if (defendData.Judge < 50) { JudgeAnim[1].Play("miss", -1, 0); } // calculate combo CurrentCombo = GetNextCombo( attackData.Button, attackData.Type, attacker.GetAttackSkill(attackData.Button) ); ComboText.text = CurrentCombo.ToString() + " Combo"; // call BattleCore BattleCore(attacker, attackData, defender, defendData, time); // post-battle logic this.LastButton = attackData.Button; this.LastType = attackData.Type; if (attacker.Hp.Value <= 0) { GameObject.Find("BeatGenerator").SetActive(false); GameObject.Find("InputManager1").SetActive(false); GameObject.Find("InputManager2").SetActive(false); attacker.Anim.speed = 0.5f; defender.Anim.speed = 0.5f; attacker.Anim.Play("lose"); StartCoroutine(EndGame((AttackerIndex == 0) ? 1 : 0)); } else if (defender.Hp.Value <= 0) { GameObject.Find("BeatGenerator").SetActive(false); GameObject.Find("InputManager1").SetActive(false); GameObject.Find("InputManager2").SetActive(false); attacker.Anim.speed = 0.5f; defender.Anim.speed = 0.5f; defender.Anim.Play("lose"); StartCoroutine(EndGame(AttackerIndex)); } }
public DefendSkill GetDefendSkill(Note.Button but) { switch (but) { case Note.Button.RED: return(this.DefendSkillList[0]); case Note.Button.BLUE: return(this.DefendSkillList[1]); case Note.Button.GREEN: return(this.DefendSkillList[2]);; default: return(null); } }
public AttackSkill GetAttackSkill(Note.Button but) { switch (but) { case Note.Button.RED: return(this.AttackSkillList[0]); case Note.Button.BLUE: return(this.AttackSkillList[1]); case Note.Button.GREEN: return(this.AttackSkillList[2]); default: return(null); } }
public void PressUp(int playerIndex, Note.Button but) { Player targetPlayer = Player[playerIndex]; AttackSkill skill = targetPlayer.GetAttackSkill(but); if (skill.IsLongButton && playerIndex == AttackerIndex && but == LastButton && LastType != InputManager.InputType.UP) { targetPlayer.Anim.SetTrigger("hit"); LastButton = Note.Button.NONE; LastType = InputManager.InputType.NONE; } }
public SpecialSkill GetSpecialSkill(Note.Button but) { switch (but) { case Note.Button.SKILL1: return(this.SpecialSkillList [0]); case Note.Button.SKILL2: return(this.SpecialSkillList [1]); default: return(null); } }
void Start() { LastButton = Note.Button.NONE; LastType = InputManager.InputType.NONE; LongButtonTime = 0; CurrentCombo = 0; AttackerIndex = 0; CancelFlip = false; Player[0].GetComponent <SpriteRenderer>().material.color = Color.red; Player[1].GetComponent <SpriteRenderer>().material.color = Color.white; DataQueue = new Queue <Note.Core>[2] { new Queue <Note.Core>(), new Queue <Note.Core>() }; }
public void DoBattle(uint id, int time) { // assign basic variables Player attacker = (this.AttackerIndex == 0) ? Player[0] : Player[1]; Player defender = (this.AttackerIndex == 0) ? Player[1] : Player[0]; Note.Core attackData = (this.AttackerIndex == 0) ? GetData(0, id) : GetData(1, id); Note.Core defendData = (this.AttackerIndex == 0) ? GetData(1, id) : GetData(0, id); // show miss layer if(attackData.Judge < 50) JudgeAnim[0].Play("miss", -1, 0); if(defendData.Judge < 50) JudgeAnim[1].Play("miss", -1, 0); // calculate combo CurrentCombo = GetNextCombo( attackData.Button, attackData.Type, attacker.GetAttackSkill(attackData.Button) ); ComboText.text = CurrentCombo.ToString() + " Combo"; // call BattleCore BattleCore(attacker, attackData, defender, defendData, time); // post-battle logic this.LastButton = attackData.Button; this.LastType = attackData.Type; if(attacker.Hp.Value <= 0) { GameObject.Find("BeatGenerator").SetActive(false); GameObject.Find("InputManager1").SetActive(false); GameObject.Find("InputManager2").SetActive(false); attacker.Anim.speed = 0.5f; defender.Anim.speed = 0.5f; attacker.Anim.Play("lose"); StartCoroutine(EndGame((AttackerIndex == 0) ? 1 : 0)); } else if(defender.Hp.Value <= 0) { GameObject.Find("BeatGenerator").SetActive(false); GameObject.Find("InputManager1").SetActive(false); GameObject.Find("InputManager2").SetActive(false); attacker.Anim.speed = 0.5f; defender.Anim.speed = 0.5f; defender.Anim.Play("lose"); StartCoroutine(EndGame(AttackerIndex)); } }
// flip attacking player public void FlipAttacker() { if (CancelFlip) { CancelFlip = false; return; } // flip attacker sign & reset combo if (this.AttackerIndex == 0) { this.AttackerIndex = 1; Player[0].GetComponent <SpriteRenderer>().material.color = Color.white; Player[1].GetComponent <SpriteRenderer>().material.color = Color.red; } else { this.AttackerIndex = 0; Player[1].GetComponent <SpriteRenderer>().material.color = Color.white; Player[0].GetComponent <SpriteRenderer>().material.color = Color.red; } this.CurrentCombo = 0; this.LastButton = Note.Button.NONE; this.LastType = InputManager.InputType.NONE; // reset all triggers to avoid unwanted animation foreach (AnimatorControllerParameter param in Player[0].Anim.parameters) { Player[0].Anim.ResetTrigger(param.name); } foreach (AnimatorControllerParameter param in Player[1].Anim.parameters) { Player[1].Anim.ResetTrigger(param.name); } // force playing basic animation Player[0].Anim.Play("basic"); Player[1].Anim.Play("basic"); }
// calculates next combo private uint GetNextCombo(Note.Button curBut, InputManager.InputType curType, AttackSkill skill) { // skill not found if (skill == null) { return(0); } // skill is long button & DOWN signal received twice else if (skill.IsLongButton && curType == InputManager.InputType.DOWN) { return(1); } // skill is long button & input is KEEP else if (skill.IsLongButton && LastButton == curBut && LastType != InputManager.InputType.UP && (curType == InputManager.InputType.KEEP || curType == InputManager.InputType.UP)) { return(2); } // new button pressed else if (curBut != Note.Button.NONE && LastButton == Note.Button.NONE) { return(1); } // button accepted -> combo increase else if (curBut != Note.Button.NONE && curBut == LastButton) { return(this.CurrentCombo % skill.TurnLength + 1); } else { return(1); } }
public void GetReady(int playerIndex, Note.Button but, InputManager.InputType type) { Player targetPlayer = Player[playerIndex]; if (playerIndex == AttackerIndex) { AttackSkill skill = targetPlayer.GetAttackSkill(but); uint combo = this.GetNextCombo(but, type, skill); // skill is not long button -> ignore long button input targetPlayer.Anim.ResetTrigger("action"); skill.PlayAnim(targetPlayer.Anim, combo, type == InputManager.InputType.UP); } else { DefendSkill skill = targetPlayer.GetDefendSkill(but); targetPlayer.Anim.ResetTrigger("action"); skill.PlayAnim(targetPlayer.Anim, 1, false); if (skill.Name == "Guard") { EffectAnim[playerIndex].Play("guardmake", -1, 0); } } }
private KeyCode ButToKeycode(Note.Button but) { switch (but) { case Note.Button.RED: return((Player == 0) ? KeyCode.S : KeyCode.Semicolon); case Note.Button.BLUE: return((Player == 0) ? KeyCode.A : KeyCode.L); case Note.Button.GREEN: return((Player == 0) ? KeyCode.D : KeyCode.Quote); case Note.Button.SKILL1: return((Player == 0) ? KeyCode.Q : KeyCode.O); case Note.Button.SKILL2: return((Player == 0) ? KeyCode.W : KeyCode.P); default: return(KeyCode.None); } }
// flip attacking player public void FlipAttacker() { if(CancelFlip) { CancelFlip = false; return; } // flip attacker sign & reset combo if(this.AttackerIndex == 0) { this.AttackerIndex = 1; Player[0].GetComponent<SpriteRenderer>().material.color = Color.white; Player[1].GetComponent<SpriteRenderer>().material.color = Color.red; } else { this.AttackerIndex = 0; Player[1].GetComponent<SpriteRenderer>().material.color = Color.white; Player[0].GetComponent<SpriteRenderer>().material.color = Color.red; } this.CurrentCombo = 0; this.LastButton = Note.Button.NONE; this.LastType = InputManager.InputType.NONE; // reset all triggers to avoid unwanted animation foreach(AnimatorControllerParameter param in Player[0].Anim.parameters) { Player[0].Anim.ResetTrigger(param.name); } foreach(AnimatorControllerParameter param in Player[1].Anim.parameters) { Player[1].Anim.ResetTrigger(param.name); } // force playing basic animation Player[0].Anim.Play("basic"); Player[1].Anim.Play("basic"); }
void Start() { LastButton = Note.Button.NONE; LastType = InputManager.InputType.NONE; LongButtonTime = 0; CurrentCombo = 0; AttackerIndex = 0; CancelFlip = false; Player[0].GetComponent<SpriteRenderer>().material.color = Color.red; Player[1].GetComponent<SpriteRenderer>().material.color = Color.white; DataQueue = new Queue<Note.Core>[2] { new Queue<Note.Core>(), new Queue<Note.Core>() }; }
public void PressUp(int playerIndex, Note.Button but) { Player targetPlayer = Player[playerIndex]; AttackSkill skill = targetPlayer.GetAttackSkill(but); if(skill.IsLongButton && playerIndex == AttackerIndex && but == LastButton && LastType != InputManager.InputType.UP) { targetPlayer.Anim.SetTrigger("hit"); LastButton = Note.Button.NONE; LastType = InputManager.InputType.NONE; } }