-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatchTurnEnemy.cs
More file actions
112 lines (93 loc) · 2.76 KB
/
MatchTurnEnemy.cs
File metadata and controls
112 lines (93 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unless denoted by a commented out link, TK wrote literally everything here
public class MatchTurnEnemy : MonoBehaviour
{
public DecisionTree tree;
public MatchTurn turn;
public EnemyObject enemy;
public PlayerObject player;
public MoveSetScript moveSet;
public Animations animate;
public bool currentGuard;
public bool prevGuard;
public void doEnemyTurn()
{
// Debug.Log("You are inside Enemy turn!");
int moveNum = -1;
enemy.turnCounter++;
// If previously guarding, stop
if (enemy.Guard && enemy.prevMove == 6)
{
animate.EnemyTurnOffGuard();
}
enemy.Guard = false;
// this function implements AI to decide which returns which move to take
moveNum = tree.runEnemyAI(player, enemy, turn, moveSet);
Debug.Log("returned enemy AI ==== " + moveNum);
currentGuard = (moveNum == 6) ? true : false;
// Hold the turn until the animations are over.
StartCoroutine(RunEnemyTurnAnimations(moveNum));
}
IEnumerator RunEnemyTurnAnimations(int moveNum)
{
// If was in guarding stance, and not guarding again, return to idle stance animation
if (enemy.prevMove == 6)
{
yield return new WaitForSeconds(0.2f);
}
// Implement move selected by Decision Tree
moveSet.doEnemyMove(moveNum);
// If Dazed this turn set to false for next turn
if (moveNum == 10)
{
enemy.Dazed = false;
}
float timeWait;
if (moveNum == 10)
{
timeWait = 1.1f;
}
else if (moveNum == 6)
{
timeWait = 0.4f;
}
else
{
timeWait = 0.8f;
}
// Run regular move animations
animate.EnemySpriteAnimation(moveNum);
yield return new WaitForSeconds(timeWait);
checkEndTurn();
}
public void checkEndTurn()
{
if (player.HP <= 0)
{
// set MatchEnd = true;
turn.MatchEnd = true;
turn.PlayerTurn = false;
turn.EnemyTurn = false;
turn.PlayerKO = true;
}
else if (enemy.HP <= 0)
{
// set MatchEnd = true;
turn.MatchEnd = true;
turn.PlayerTurn = false;
turn.EnemyTurn = false;
turn.EnemyKO = true;
}
else
{
// yield turn
yieldEnemyTurn();
}
}
public void yieldEnemyTurn()
{
turn.EnemyTurn = false;
}
}