void AttackBack() { CombatBean playerAttack = combatQueue.Peek()[0]; CombatBean enemyAttack = combatQueue.Peek()[1]; if (enemyAttack != null) { int winner = combatQueue.Dequeue(); Debug.Log($"Winner is: {winner}"); if (playerAttack != null) { playerAttack.Self.Attack(playerAttack, enemyAttack.Self.gameObject); outstandingAttacks += 1; } else { Debug.Log("No Attack Recorded"); } if (winner == 1) { enemyAttack.Self.Lose(); } else if (winner == -1) { //End screen; } enemyAttack.Self.Attack(enemyAttack, player); outstandingAttacks += 1; StartCoroutine(WaitForAttacks()); } else { StartTime(); } }
public void EnableEnemyLineRenderer(CombatBean attack) { attack.Self.LR.gameObject.GetComponent <LineRenderer>(); attack.Self.LR.enabled = true; attack.Self.LR.SetPosition(0, attack.PlayerPosition); attack.Self.LR.SetPosition(1, attack.Position); }
public CombatBean[] Peek() { CombatBean[] peek = new CombatBean[2]; if (playerAttacks.Count != 0) { peek[0] = playerAttacks.Peek(); } if (enemyAttacks.Count != 0) { peek[1] = enemyAttacks.Peek(); } return(peek); }
public void AddEnemyAttack(CombatBean attack) { attack.Self.StopTime(); player.GetComponent <AttackMoves>().StopTime(); playerController.StopTime(); attackAnimators.Add(attack.Self); combatQueue.enqueueEnemyAttack(attack); enemyTempQueue.Enqueue(attack); if (!timer) { Debug.Log("Timer on"); timer = true; StartCoroutine(DequeueEnemyAttacks()); } }
public void Attack(CombatBean attack, GameObject other) { rb.constraints = (RigidbodyConstraints2D.FreezeRotation); if (attack.Attack == CombatBean.Attacks.slice) { Slice(other); } else if (attack.Attack == CombatBean.Attacks.feint) { Feint(other); } else if (attack.Attack == CombatBean.Attacks.parry) { Parry(other); } else { GameManager.instance.AttackFinish(); } }
IEnumerator DequeueEnemyAttacks() { CombatBean e = enemyTempQueue.Dequeue(); EnableEnemyLineRenderer(e); yield return(new WaitForSeconds(ENEMYVISIONTIMER)); if (enemyTempQueue.Count > 0) { Debug.Log($"Queue not empty: {enemyTempQueue.Count}"); StartCoroutine(DequeueEnemyAttacks()); } else { Debug.Log($"Queue empty: Starting attacks"); DisableEnemyLooking(); StopTime(); StartCoroutine(EnableAttackBack()); } }
public int Battle(CombatBean other) { if (other == null) { Debug.Log("No player attack detected"); return(AttackList[(int)Attack](null)); } if ((this.Position - other.PlayerPosition).magnitude > 1f) { Debug.Log("Cursor Position:" + this.position); Debug.Log("Target Position:" + other.playerPosition); Debug.Log("Position Failed"); Fail(); } if ((other.Position - this.PlayerPosition).magnitude > 1f) { //other.Fail(); } return(AttackList[(int)Attack](other)); }
private int Parry(CombatBean other) { if (other == null) { return(-1); } else if (other.Attack == Attacks.slice) { return(1); } else if (other.Attack == Attacks.parry) { return(0); } else if (other.Attack == Attacks.feint) { return(-1); } else { return(0); } }
public void AddPlayerAttack(CombatBean attack) { combatQueue.enqueuePlayerAttack(attack); }
public void enqueueEnemyAttack(CombatBean attack) { enemyAttacks.Enqueue(attack); enemyAttackCount++; }
public void enqueuePlayerAttack(CombatBean attack) { playerAttacks.Enqueue(attack); playerAttackCount++; }