forked from super-jenius/Untold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WorldStoryBase.as
183 lines (164 loc) · 5.73 KB
/
WorldStoryBase.as
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
177
178
179
180
181
182
// World Story base class
// Allows stories to be placed throughout the game world
// When user is within range of specified location, an icon is displayed in the notification area
// If icon is clicked, then an action is performed (specified in subclass)
// If users exits the range of the location, the icon is removed
// There can be multiple icons active at one time
class WorldStoryBase
{
public var m_StoryID;
public var m_Type; // story, art, video, etc.
public var m_StoryTitle;
public var m_SubTitle = "";
public var m_AddlInfo = "";
public var m_Teaser; // Optional FIFO teaser message when player gets in range
public var m_LocationTier;
public var m_IconType = "BrokenItemsIcon";
public var m_USIcon;
public var m_AtLocation;
public var m_IntervalID;
public var m_Player:PlayerInfo;
public function WorldStoryBase()
{
m_Player = new PlayerInfo();
}
public function LoadXML(storyNode:XMLNode)
{
m_StoryID = storyNode.attributes.id;
m_Type = storyNode.attributes.type;
m_StoryTitle = storyNode.attributes.title;
//_root.fifo.SlotShowFIFOMessage(m_StoryTitle);
if (storyNode.attributes.subtitle) {
m_SubTitle = storyNode.attributes.subtitle;
}
m_Teaser = storyNode.attributes.teaser;
this.SetLocation(Number(storyNode.attributes.playField), Number(storyNode.attributes.x), Number(storyNode.attributes.y),
Number(storyNode.attributes.z), Number(storyNode.attributes.distance), Number(storyNode.attributes.yDistance));
}
public function SetLocation(playField:Number, x:Number, y:Number, z:Number, distance:Number, yDistance:Number)
{
//_root.fifo.SlotShowFIFOMessage("WorldStoryBase.SetLocation()");
m_LocationTier = new LocationTier();
m_LocationTier.m_Player = m_Player;
m_LocationTier.m_Lore = true;
m_LocationTier.SetLocation(playField, x, y, z, distance, yDistance);
}
// Start tracking location
public function StartTracking()
{
//_root.fifo.SlotShowFIFOMessage("WorldStoryBase.StartTracking()");
m_AtLocation = false;
m_IntervalID = setInterval(this, "CheckLocation", 500);
}
public function StopTracking()
{
clearInterval(m_IntervalID);
this.DestroyIcon();
}
public function CheckLocation()
{
//_root.fifo.SlotShowFIFOMessage("WorldStory.CheckLocation()");
if (m_LocationTier.CheckLocation() == true) {
if (m_AtLocation == false) { // If we were already at the location, do nothing
m_AtLocation = true;
this.DisplayTeaser();
this.ShowIcon();
}
} else {
if (m_AtLocation == true) { // If we were already outside the location do nothing
m_AtLocation = false;
this.DestroyIcon();
}
}
}
public function DisplayTeaser()
{
// Play teaser sound
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_achievement_get.xml");
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_group_invited.xml");
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_loot_bag_open.xml");
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_loot_bag_take_item.xml");
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_power_wheel_movement.xml"); // subtle
m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_purchase_power.xml"); // varies with each play
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_spend_skill_point.xml");
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_trade_success.xml");
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_window_open.xml"); // subtle but audible
//m_Player.m_Character.AddEffectPackage("sound_fxpackage_GUI_PvP_MiniGame_PopUp.xml");
// Display optional teaser
if (m_Teaser <> undefined && m_Teaser <> null && m_Teaser <> "") {
_root.fifo.SlotShowFIFOMessage(m_Teaser);
}
}
public function ShowIcon()
{
var link = _root.animawheellink;
// Create icon if it doesn't already exist
if (m_USIcon == undefined || link["m_USIcon_" + m_StoryID] == undefined)
{
m_USIcon = link.attachMovie(m_IconType, "m_USIcon_" + m_StoryID, link.getNextHighestDepth());
link.SetVisible(m_USIcon, false);
m_USIcon.createTextField("m_NotificationText", m_USIcon.getNextHighestDepth(), 0, 1, 35, 33.10);
m_USIcon.m_NotificationText.text = "US";
var fmt:TextFormat = new TextFormat();
fmt.align = "center";
fmt.bold = true;
fmt.color = 16777215;
fmt.font = "Futura Heavy Fix";
fmt.size = 23;
fmt.leading = 2;
m_USIcon.m_NotificationText.setTextFormat(fmt);
// m_USIcon.fmt = m_USIcon.m_NotificationText.getTextFormat();
link.CreateRealTooltip(m_USIcon, "Untold Stories\nof The Secret World", m_Type + ": " + m_StoryTitle + "\n" + m_SubTitle + m_AddlInfo);
// Single click opens URL. Double-click hides icon.
var intervalID = 0;
var clickNum = 0;
var thisStory = this;
m_USIcon.onPress = function(){
clickNum++;
if (clickNum == 1) {
intervalID = setInterval(function() {
// Single click
clickNum = 0;
clearInterval(intervalID);
thisStory.HideIcon();
thisStory.PerformAction();
//_root.fifo.SlotShowFIFOMessage("Single click");
}, 400);
} else {
// Double click
clickNum = 0;
clearInterval(intervalID);
thisStory.HideIcon();
//_root.fifo.SlotShowFIFOMessage("Double click");
}
}
}
// Show icon
link.SetVisible(m_USIcon, true);
}
public function HideIcon()
{
if (m_USIcon) {
var link = _root.animawheellink;
link.SetVisible(m_USIcon, false);
}
}
public function DestroyIcon()
{
if (m_USIcon) {
this.HideIcon();
m_USIcon.removeMovieClip();
m_USIcon = undefined;
}
}
public function PerformAction()
{
// Action specified in subclass
}
// Cleanup function should be called before releasing object
public function Cleanup()
{
this.StopTracking();
m_LocationTier = undefined;
}
}