void AIFight() { var intNum = attackList[parseNum]; switch (intNum) { case 1: Debug.Log("attack 1"); characterController.Attack(1); parseNum++; checkParseNum(); intNum = attackList[parseNum]; CombatHitController.GetHit(); break; case 2: Debug.Log("attack 2"); characterController.Attack(2); parseNum++; checkParseNum(); intNum = attackList[parseNum]; CombatHitController.GetHit(); break; case 3: Debug.Log("Attack 3"); characterController.AttackKick(1); checkParseNum(); parseNum++; CombatHitController.GetHit(); intNum = attackList[parseNum]; break; case 4: Debug.Log("attack 4"); characterController.AttackKick(2); checkParseNum(); parseNum++; intNum = attackList[parseNum]; CombatHitController.GetHit(); break; } }
void FixedUpdate() { Vector3 MPPosition = MainPlayer.transform.position; Vector3 AIPosition = AIPlayer.transform.position; distance = Vector3.Distance(MPPosition, AIPosition); HealthText.text = Health.ToString(); if (Input.GetMouseButtonDown(0)) { MainPlayer.transform.LookAt(AIPlayer.transform); var rndNum = rnd.Next(1, 2); characterController.Attack(rndNum); if (distance <= 3f) { AIHealthManager.AIHit(); if (AIHealthManager.AIDead) { AIPlayer.GetComponent <NavMeshAgent>().enabled = false; AIPlayer.GetComponent <AIController>().enabled = false; } } Debug.Log("Fist Punch!"); } if (Input.GetMouseButtonDown(1)) { MainPlayer.transform.LookAt(AIPlayer.transform); var rndNum = rnd.Next(1, 2); characterController.AttackKick(rndNum); if (distance <= 3f) { elapsed += Time.deltaTime; AIHealthManager.AIHit(); if (AIHealthManager.AIDead) { AIPlayer.GetComponent <AIController>().enabled = false; AIPlayer.GetComponent <NavMeshAgent>().enabled = false; } } Debug.Log("Kick attack!"); } if (Health <= 0) { GameOverPanel.SetActive(true); } }
void OnGUI() { if (!rpgCharacter.isDead) { if (rpgCharacter.canAction && !rpgCharacter.isRelax && !rpgCharacter.useNavMesh) { if (rpgCharacter.isGrounded) { if (GUI.Button(new Rect(25, 15, 100, 30), "Roll Forward")) { rpgCharacter.targetDashDirection = transform.forward; StartCoroutine(rpgCharacter._Roll(1)); } if (GUI.Button(new Rect(130, 15, 100, 30), "Roll Backward")) { rpgCharacter.targetDashDirection = -transform.forward; StartCoroutine(rpgCharacter._Roll(3)); } if (GUI.Button(new Rect(25, 45, 100, 30), "Roll Left")) { rpgCharacter.targetDashDirection = -transform.right; StartCoroutine(rpgCharacter._Roll(4)); } if (GUI.Button(new Rect(130, 45, 100, 30), "Roll Right")) { rpgCharacter.targetDashDirection = transform.right; StartCoroutine(rpgCharacter._Roll(2)); } //ATTACK LEFT if (GUI.Button(new Rect(25, 85, 100, 30), "Attack L")) { rpgCharacter.Attack(1); } //ATTACK RIGHT if (GUI.Button(new Rect(130, 85, 100, 30), "Attack R")) { rpgCharacter.Attack(2); } if (rpgCharacter.weapon == Weapon.UNARMED) { if (GUI.Button(new Rect(25, 115, 100, 30), "Left Kick")) { rpgCharacter.AttackKick(1); } if (GUI.Button(new Rect(130, 115, 100, 30), "Right Kick")) { rpgCharacter.AttackKick(2); } } if (GUI.Button(new Rect(30, 240, 100, 30), "Get Hit")) { rpgCharacter.GetHit(); } } if (rpgCharacter.canJump || rpgCharacter.canDoubleJump) { if (rpgCharacter.isGrounded) { if (GUI.Button(new Rect(25, 165, 100, 30), "Jump")) { if (rpgCharacter.canJump && rpgCharacter.isGrounded) { StartCoroutine(rpgCharacter._Jump()); } } } else { if (GUI.Button(new Rect(25, 165, 100, 30), "Double Jump")) { if (rpgCharacter.canDoubleJump && !rpgCharacter.isDoubleJumping) { StartCoroutine(rpgCharacter._Jump()); } } } } if (rpgCharacter.isGrounded) { if (GUI.Button(new Rect(30, 270, 100, 30), "Death")) { rpgCharacter.Death(); } } } //Character NavMesh navigation useNav = GUI.Toggle(new Rect(25, 200, 100, 30), useNav, "Use NavMesh"); if (useNav) { if (navToggle == false) { rpgCharacter.useNavMesh = true; navToggle = true; } } else { rpgCharacter.useNavMesh = false; navToggle = false; } } if (rpgCharacter.isDead) { if (GUI.Button(new Rect(30, 270, 100, 30), "Revive")) { rpgCharacter.Revive(); } } }