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
|
/*
*
* Adventure Creator
* by Chris Burton, 2013-2014
*
* "MenuTimer.cs"
*
* This MenuElement can be used in conjunction with MenuDialogList to create
* timed conversations, "Walking Dead"-style.
*
*/
using UnityEngine;
using AC;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class MenuTimer : MenuElement
{
public Texture2D timerTexture;
public override void Declare ()
{
isVisible = true;
isClickable = false;
numSlots = 1;
SetSize (new Vector2 (20f, 5f));
base.Declare ();
}
public void CopyTimer (MenuTimer _element)
{
timerTexture = _element.timerTexture;
base.Copy (_element);
}
#if UNITY_EDITOR
public override void ShowGUI ()
{
EditorGUILayout.BeginVertical ("Button");
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.LabelField ("Timer texture:", GUILayout.Width (145f));
timerTexture = (Texture2D) EditorGUILayout.ObjectField (timerTexture, typeof (Texture2D), false, GUILayout.Width (70f), GUILayout.Height (30f));
EditorGUILayout.EndHorizontal ();
EditorGUILayout.EndVertical ();
EndGUI ();
}
#endif
public override void Display (GUIStyle _style, int _slot, float zoom)
{
if (timerTexture)
{
if (Application.isPlaying)
{
if (GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInput>())
{
PlayerInput playerInput = GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInput>();
if (playerInput.activeConversation && playerInput.activeConversation.isTimed)
{
Rect timerRect = relativeRect;
timerRect.width = slotSize.x / 100f * AdvGame.GetMainGameViewSize().x * playerInput.activeConversation.GetTimeRemaining ();
GUI.DrawTexture (ZoomRect (timerRect, zoom), timerTexture, ScaleMode.StretchToFill, true, 0f);
}
}
}
else
{
GUI.DrawTexture (ZoomRect (relativeRect, zoom), timerTexture, ScaleMode.StretchToFill, true, 0f);
}
}
base.Display (_style, _slot, zoom);
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|