I am writing a turn-based game, researching a simple state machine. I haven’t used NC yet, mostly FC and converting to code as I go. Need to hit myself a kick to work some more hours!!
OK so I’m thinking for my needs I need a simple state machine. I see a few different patterns out there, thought I would post the easiest and ask if anyone could share a similar design from NC.
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
publicclassGameStates:MonoBehaviour{
publicenumGameState{
START,
PLAYERCHOICE,
ENEMYCHOICE,
LOSE,
WIN
}
privateGameState currentState;
privateGameState lastState;
voidStart(){
currentState=GameState.START;
}
voidUpdate(){
switch(currentState){
case(GameState.START):
if(currentState!=lastState){
}
lastState=currentState;
break;
case(GameState.PLAYERCHOICE):
if(currentState!=lastState){
}
lastState=currentState;
break;
case(GameState.ENEMYCHOICE):
if(currentState!=lastState){
}
lastState=currentState;
break;
case(GameState.LOSE):
if(currentState!=lastState){
}
lastState=currentState;
break;
case(GameState.WIN):
if(currentState!=lastState){
}
lastState=currentState;
break;
}
}
}
I modified the above pattern to include the “lastState” control variable because I can’t figure how it would work without it.
Can anyone suggest the NC equivalent? Any interest in working on this to come up with a few different types?
Rix
Author
Posts
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.