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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
/*
*
* Adventure Creator
* by Chris Burton, 2013-2014
*
* "ActionSendMessage.cs"
*
* This action calls "SendMessage" on a GameObject.
* Both standard messages, and custom ones with paremeters, can be sent.
*
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using AC;
#if UNITY_EDITOR
using UnityEditor;
#endif
[System.Serializable]
public class ActionSendMessage : Action
{
public int constantID = 0;
public GameObject linkedObject;
public MessageToSend messageToSend;
public enum MessageToSend { TurnOn, TurnOff, Interact, Kill, Custom };
public string customMessage;
public bool sendValue;
public int customValue;
public ActionSendMessage ()
{
this.isDisplayed = true;
title = "Object: Send message";
}
override public float Run ()
{
if (isAssetFile && constantID != 0)
{
// Attempt to find the correct scene object
ConstantID idObject = Serializer.returnComponent <ConstantID> (constantID);
if (idObject != null)
{
linkedObject = idObject.gameObject;
}
else
{
linkedObject = null;
}
}
if (linkedObject)
{
if (messageToSend == MessageToSend.TurnOn)
{
linkedObject.SendMessage ("TurnOn");
}
else if (messageToSend == MessageToSend.TurnOff)
{
linkedObject.SendMessage ("TurnOff");
}
else if (messageToSend == MessageToSend.Interact)
{
linkedObject.SendMessage ("Interact");
}
else if (messageToSend == MessageToSend.Kill)
{
linkedObject.SendMessage ("Kill");
}
else
{
if (!sendValue)
{
linkedObject.SendMessage (customMessage);
}
else
{
linkedObject.SendMessage (customMessage, customValue);
}
}
}
return 0f;
}
override public int End (List<AC.Action> actions)
{
// If the linkedObject is an immediately-starting ActionList, don't end the cutscene
if (linkedObject && messageToSend == MessageToSend.Interact && linkedObject.GetComponent <Cutscene>())
{
Cutscene tempAction = linkedObject.GetComponent<Cutscene>();
if (tempAction.triggerTime == 0f)
{
return -2;
}
}
return (base.End(actions));
}
#if UNITY_EDITOR
public override void ShowGUI ()
{
if (isAssetFile)
{
constantID = EditorGUILayout.IntField ("Object to affect (ID):", constantID);
}
else
{
linkedObject = (GameObject) EditorGUILayout.ObjectField ("Object to affect:", linkedObject, typeof(GameObject), true);
}
messageToSend = (MessageToSend) EditorGUILayout.EnumPopup ("Message to send:", messageToSend);
if (messageToSend == MessageToSend.Custom)
{
customMessage = EditorGUILayout.TextField ("Method name:", customMessage);
sendValue = EditorGUILayout.Toggle ("Pass integer to method?", sendValue);
if (sendValue)
{
customValue = EditorGUILayout.IntField ("Integer to send:", customValue);
}
}
AfterRunningOption ();
}
public override string SetLabel ()
{
string labelAdd = "";
if (linkedObject)
{
if (messageToSend == MessageToSend.TurnOn)
{
labelAdd += " ('Turn on' ";
}
else if (messageToSend == MessageToSend.TurnOff)
{
labelAdd += " ('Turn off' ";
}
else if (messageToSend == MessageToSend.Interact)
{
labelAdd += " ('Interact' ";
}
else if (messageToSend == MessageToSend.Kill)
{
labelAdd += " ('Kill' ";
}
else
{
labelAdd += " ('" + customMessage + "' ";
}
labelAdd += " to " + linkedObject.name + ")";
}
return labelAdd;
}
#endif
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|