Advertisement
Guest User

Untitled

a guest
Jul 15th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. class Tombstone : ZilchComponent
  2. {
  3.  
  4. [Property]
  5. var TimerMax : Integer = 100;
  6.  
  7. var Timer : Integer = 0;
  8.  
  9. [Property]
  10. var MaxUses : Integer = 3;
  11.  
  12. var Uses : Integer = 3;
  13.  
  14. [Property]
  15. var CooldownValue : Real = 5.0;
  16.  
  17. var Cooldown : Real = 0.0;
  18.  
  19. [Property]
  20. var ArchetypeToSpawn : Archetype = null;
  21.  
  22. function Initialize(init : CogInitializer)
  23. {
  24. this.Cooldown = this.CooldownValue;
  25.  
  26. this.Uses = this.MaxUses;
  27.  
  28. this.Timer = this.TimerMax;
  29.  
  30. Zero.Connect(this.Owner, Events.CollisionPersisted, this.CollisionPersisted);
  31. Zero.Connect(this.Space, Events.LogicUpdate, this.OnLogicUpdate);
  32. Zero.Connect(this.Owner, Events.CollisionStarted, this.OnCollisionStarted);
  33. Zero.Connect(this.Owner, Events.CollisionEnded, this.OnCollisionEnded);
  34. }
  35.  
  36. function OnLogicUpdate(event : UpdateEvent)
  37. {
  38. this.Owner.SpriteText.Text = ("`this.Cooldown` `this.Timer`");
  39.  
  40. var particles = this.Owner.FindChildByName("TombstoneParticles");
  41.  
  42. if (this.Uses > 0)
  43. {
  44. particles.Transform.Translation = local Real3(0.0, 0.0, 0.0);
  45. }
  46. else
  47. {
  48.  
  49. particles.Transform.Translation = local Real3(100000.0, 0.0, 0.0);
  50. }
  51.  
  52. if(this.Uses != this.MaxUses)
  53. {
  54. this.Cooldown -= event.Dt;
  55. }
  56.  
  57. if(this.Cooldown < 0.0)
  58. {
  59. if(this.Uses < this.MaxUses)
  60. {
  61. this.Uses += 1;
  62. }
  63.  
  64. this.Cooldown = this.CooldownValue;
  65. }
  66.  
  67. this.Timer += 1;
  68. }
  69.  
  70. function CollisionPersisted (event : CollisionEvent)
  71. {
  72. var thingCollidedWith = event.OtherObject.Name;
  73.  
  74. if(thingCollidedWith == "Ghost")
  75. {
  76. if (this.Timer > this.TimerMax)
  77. {
  78. this.Timer = this.TimerMax;
  79. }
  80.  
  81. this.Timer -= 2;
  82. }
  83.  
  84. if(thingCollidedWith == "Gravedigger")
  85. {
  86. //this.Timer += 1;
  87. }
  88.  
  89. if (this.Timer < 0 && this.Uses > 0) //Spawn Zombie
  90. {
  91.  
  92. var tombstones = this.Space.FindAllObjectsByName("Tombstone");
  93.  
  94. this.Space.CreateAtPosition(this.ArchetypeToSpawn, this.Owner.Transform.Translation);
  95.  
  96. this.Timer = this.TimerMax + 100;
  97.  
  98. this.Uses -= 1;
  99.  
  100. /*if (this.Uses == 0)
  101. {
  102. this.Uses -= 1;
  103. }*/
  104.  
  105. this.Cooldown = this.CooldownValue;
  106. }
  107. }
  108.  
  109. function OnCollisionStarted(event : CollisionEvent)
  110. {
  111. var thingCollidedWith = event.OtherObject;
  112.  
  113. if(thingCollidedWith.Name == "Zombie" && thingCollidedWith.ZombiePathing.IsPickedUp == true)
  114. {
  115. var player = this.Space.FindObjectByName("Gravedigger");
  116.  
  117. thingCollidedWith.Destroy();
  118.  
  119. //this.IsFilled = true;
  120.  
  121. this.Timer = this.TimerMax;
  122.  
  123. player.GraveDiggerPickup.IsCarrying = false;
  124. player.GraveDiggerPickup.DropDelay = 0.1;
  125. player.PlayerController.Speed = player.PlayerController.SpeedMax;
  126. }
  127. }
  128.  
  129. function OnCollisionEnded(event : CollisionEvent)
  130. {
  131. var thingCollidedWith = event.OtherObject;
  132.  
  133. if(thingCollidedWith.Name == "Ghost")
  134. {
  135. this.Timer = this.TimerMax + 100;
  136. }
  137. }
  138.  
  139. }
  140.  
  141.  
  142. On Wed, Jul 15, 2015 at 3:11 PM, Max Whitehead <max.blackllama@gmail.com> wrote:
  143.  
  144.  
  145. On Wed, Jul 15, 2015 at 3:01 PM, Isaac Dugaw <izpdugaw@gmail.com> wrote:
  146.  
  147.  
  148. On Wed, Jul 15, 2015 at 2:52 PM, Isaac Dugaw <izpdugaw@gmail.com> wrote:
  149. re-updated tombstone code:
  150.  
  151. http://pastebin.com/WHaA3TwZ
  152.  
  153. On Wed, Jul 15, 2015 at 2:12 PM, Isaac Dugaw <izpdugaw@gmail.com> wrote:
  154. Updated Tombstone Code:
  155.  
  156. http://pastebin.com/Vf4M7kjf
  157.  
  158. On Wed, Jul 15, 2015 at 1:58 PM, Isaac Dugaw <izpdugaw@gmail.com> wrote:
  159. Updated Torch Code:
  160.  
  161. http://pastebin.com/bKr2DgL3
  162.  
  163. On Wed, Jul 15, 2015 at 1:44 PM, Max Whitehead <max.blackllama@gmail.com> wrote:
  164.  
  165.  
  166. 2015-07-15 13:38 GMT-07:00 Isaac Dugaw <izpdugaw@gmail.com>:
  167.  
  168. 2015-07-15 13:36 GMT-07:00 Isaac Dugaw <izpdugaw@gmail.com>:
  169.  
  170.  
  171. On Wed, Jul 15, 2015 at 1:24 PM, Isaac Dugaw <izpdugaw@gmail.com> wrote:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement