Subversion Repository Public Repository

Nextrek

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
/*
 *
 *	Adventure Creator
 *	by Chris Burton, 2013-2014
 *	
 *	"SceneHandler.cs"
 * 
 *	This script stores the gameState variable, which is used by
 *	other scripts to determine if the game is running normal gameplay,
 *	in a cutscene, paused, or displaying conversation options.
 * 
 */

using UnityEngine;
using AC;

public class StateHandler : MonoBehaviour
{
	
	public GameState gameState = GameState.Normal;
	
	private GameState lastGameplayState = GameState.Normal;
	private GameState lastGameplayState_Backup = GameState.Normal;
	
	
	private void Awake ()
	{
		DontDestroyOnLoad(this);
	}
	
	
	private void Update ()
	{
		if (gameState != GameState.Paused)
		{
			lastGameplayState = gameState;
		}
	}
	
	
	public void RestoreLastGameplayState ()
	{
		gameState = lastGameplayState;
	}
	
	
	public GameState GetLastGameplayState ()
	{
		return lastGameplayState;
	}
	
	
	public void BackupLastGameplayState ()
	{
		lastGameplayState_Backup = lastGameplayState;
	}
	
	
	public void UpdateLastGameplayState ()
	{
		lastGameplayState = lastGameplayState_Backup;
	}


	public void TurnOnAC ()
	{
		gameState = GameState.Normal;
	}
	
	
	public void TurnOffAC ()
	{
		if (GameObject.FindWithTag (Tags.gameEngine))
		{
			if (GameObject.FindWithTag (Tags.gameEngine).GetComponent <ActionListManager>())
			{
				GameObject.FindWithTag (Tags.gameEngine).GetComponent <ActionListManager>().KillAllLists ();
			}

			if (GameObject.FindWithTag (Tags.gameEngine).GetComponent <Dialog>())
			{
				GameObject.FindWithTag (Tags.gameEngine).GetComponent <Dialog>().KillDialog ();
			}
		}
		
		Moveable[] moveables = FindObjectsOfType (typeof (Moveable)) as Moveable[];
		foreach (Moveable moveable in moveables)
		{
			moveable.Kill ();
		}

		Char[] chars = FindObjectsOfType (typeof (Char)) as Char[];
		foreach (Char _char in chars)
		{
			_char.EndPath ();
		}
		
		gameState = GameState.Cutscene;
	}

}

Commits for Nextrek/SpaceCrew/SpaceCrew/Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs

Diff revisions: vs.
Revision Author Commited Message
83 FMMortaroli picture FMMortaroli Tue 13 May, 2014 11:32:51 +0000