Elin Decompiled Documentation EA 23.187 Stable
Loading...
Searching...
No Matches
ZoneEventDefenseGame.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3
5{
6 [JsonProperty]
7 public int wave;
8
9 [JsonProperty]
10 public int turns;
11
12 [JsonProperty]
13 public int hornTimer;
14
15 [JsonProperty]
16 public int kills;
17
18 [JsonProperty]
19 public int allyCall;
20
21 [JsonProperty]
22 public int allyTimer;
23
24 [JsonProperty]
25 public int bonus;
26
27 [JsonProperty]
28 public bool retreated;
29
30 public ZoneInstanceRandomQuest instance => EClass._zone.instance as ZoneInstanceRandomQuest;
31
32 public bool CanRetreat
33 {
34 get
35 {
36 if (rounds >= 100)
37 {
38 return hornTimer <= 0;
39 }
40 return false;
41 }
42 }
43
44 public bool CanCallAlly
45 {
46 get
47 {
48 if (allyCall == 0)
49 {
50 return rounds >= 50;
51 }
52 return false;
53 }
54 }
55
56 public override string TextWidgetDate => "defenseWave".lang(wave.ToString() ?? "", kills.ToString() ?? "", EClass._zone.DangerLv.ToString() ?? "") + ((instance != null && retreated) ? "defenseRetreating" : (CanRetreat ? "defenseRetreat" : "")).lang() + (CanCallAlly ? "defenseAlly" : "").lang();
57
58 public virtual Chara CreateChara()
59 {
60 return CharaGen.CreateFromFilter("c_wilds");
61 }
62
63 public override void OnVisit()
64 {
66 {
67 QuestDefenseGame.lastWave = wave;
68 QuestDefenseGame.bonus = bonus;
69 return;
70 }
71 int num = (base.quest.FameContent ? (EClass.pc.FameLv / 100 * 50) : 0);
72 EClass._zone._dangerLv = 5 + num;
73 bonus += num / 10;
74 Point nearestPoint = EClass._map.GetCenterPos().GetNearestPoint(allowBlock: false, allowChara: false);
75 EClass._zone.AddCard(ThingGen.Create("stone_defense"), nearestPoint).Install().isNPCProperty = true;
76 EClass._zone.AddCard(ThingGen.Create("core_defense"), nearestPoint).Install().isNPCProperty = false;
77 EClass._zone.SetBGM(107);
78 Msg.Say("defense_start");
79 NextWave();
80 }
81
82 public void NextWave(int add = 0)
83 {
84 wave++;
85 turns = 0;
86 EClass._zone._dangerLv += ((EClass._zone.DangerLv >= 100) ? (EClass._zone.DangerLv / 100 * 5 + 5) : 5);
87 SE.Play("warhorn");
88 Msg.Say("warhorn");
89 Msg.Say("defense_wave", wave.ToString() ?? "", EClass._zone.DangerLv.ToString() ?? "");
90 Spawn(2 + base.quest.difficulty + add);
91 AggroEnemy();
92 }
93
94 public override void _OnTickRound()
95 {
96 QuestDefenseGame.lastWave = wave;
97 QuestDefenseGame.bonus = bonus;
98 Debug.Log("wave:" + wave + " turns:" + turns + " rounds:" + rounds);
99 turns++;
100 if (hornTimer > 0)
101 {
102 hornTimer--;
103 }
104 if (turns <= 3 + base.quest.difficulty)
105 {
106 Spawn();
107 }
108 if (turns == 10 && wave % 5 == 0)
109 {
110 Rand.SetSeed(wave + base.quest.uid);
111 SpawnBoss(((wave >= 10) ? (wave * 2) : 0) > EClass.rnd(100));
112 Rand.SetSeed();
113 }
114 if (turns == 20)
115 {
116 NextWave();
117 }
118 AggroEnemy();
119 if (allyTimer > 0)
120 {
121 allyTimer--;
122 if (allyTimer == 0)
123 {
124 allyCall--;
125 }
126 }
127 }
128
129 public void Horn_Next()
130 {
131 Msg.Say("defense_start");
132 int add = 0;
133 if (turns <= 3)
134 {
135 Msg.Say("defense_bonus", bonus.ToString() ?? "");
136 bonus++;
137 add = 1 + base.quest.difficulty;
138 }
139 NextWave(add);
140 hornTimer += 10;
141 if (hornTimer > 100)
142 {
143 hornTimer = 100;
144 }
145 }
146
147 public void Horn_Retreat()
148 {
149 SE.Play("warhorn");
150 Msg.Say("warhorn");
151 Msg.Say("defense_retreat");
152 retreated = true;
153 instance.status = ZoneInstance.Status.Success;
155 }
156
157 public void Horn_Ally()
158 {
159 SE.Play("warhorn");
160 Msg.Say("warhorn");
161 ActEffect.ProcAt(EffectId.Summon, 100, BlessedState.Normal, EClass.pc, EClass.pc, EClass.pc.pos, isNeg: false, new ActRef
162 {
163 n1 = "special_force"
164 });
165 allyCall++;
166 allyTimer += 100;
167 }
168
169 public override void OnCharaDie(Chara c)
170 {
171 if (!c.IsPCParty && !c.IsPCPartyMinion)
172 {
173 kills++;
174 }
175 }
176}
BlessedState
Definition: BlessedState.cs:2
EffectId
Definition: EffectId.cs:2
static void Proc(EffectId id, Card cc, Card tc=null, int power=100, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:901
static void ProcAt(EffectId id, int power, BlessedState state, Card cc, Card tc, Point tp, bool isNeg, ActRef actRef=default(ActRef))
Definition: ActEffect.cs:411
bool isNPCProperty
Definition: Card.cs:540
Point pos
Definition: Card.cs:57
static Chara CreateFromFilter(string id, int lv=-1, int levelRange=-1)
Definition: CharaGen.cs:22
Definition: Chara.cs:10
override bool IsPCParty
Definition: Chara.cs:613
override bool IsPCPartyMinion
Definition: Chara.cs:637
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static int rnd(long a)
Definition: EClass.cs:58
static Chara pc
Definition: EClass.cs:14
bool isLoading
Definition: Game.cs:238
Point GetCenterPos()
Definition: MapBounds.cs:52
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: Point.cs:9
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false, int minRadius=0)
Definition: Point.cs:607
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
virtual Chara CreateChara()
override void OnCharaDie(Chara c)
override void _OnTickRound()
ZoneInstanceRandomQuest instance
override string TextWidgetDate
void AggroEnemy(int chance=100)
void SpawnBoss(bool evolve=false)
void Spawn(int num=1)
int rounds
Definition: ZoneEvent.cs:9
void SetBGM(List< int > ids, bool refresh=true)
Definition: Zone.cs:2861
override int DangerLv
Definition: Zone.cs:107
Card AddCard(Card t, Point point)
Definition: Zone.cs:1937
Definition: ActRef.cs:2