Guest User

Untitled

a guest
Mar 12th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. package;
  2.  
  3. import flixel.FlxG;
  4. import flixel.tile.FlxTilemap;
  5. import flixel.util.FlxPath;
  6. import flixel.FlxSprite;
  7.  
  8. import flixel.util.FlxPoint;
  9.  
  10. import flixel.group.FlxTypedGroup;
  11. import flixel.effects.particles.FlxParticle;
  12. import flixel.effects.particles.FlxEmitter;
  13.  
  14. import flixel.util.FlxMath;
  15. import flixel.util.FlxVelocity;
  16. import flixel.util.FlxSpriteUtil;
  17. import flixel.util.FlxAngle;
  18. import flixel.util.FlxTimer;
  19. import flixel.util.FlxRandom;
  20.  
  21.  
  22. class ZombieChibi extends FlxSprite
  23. {
  24.  
  25. private var _player:Player;
  26. private var _map:FlxTilemap;
  27.  
  28.  
  29. public var index:Int;
  30.  
  31. public var moneyGain:Bool = true;
  32. public var SlimeClass:Int = 0;
  33.  
  34. public var randCatch:Int = 0;
  35.  
  36. public var bonked:Bool;
  37.  
  38. public var collidesMap:Bool;
  39.  
  40. public var SEEKER:Bool;
  41. public var WANDERER:Bool;
  42.  
  43. public var lastKnownX:Float;
  44. public var lastKnownY:Float;
  45.  
  46. public var WanderWait:Float = 12;
  47.  
  48. public var cooldownTimer:FlxTimer;
  49. public var hitSomething:Bool;
  50.  
  51. public var _moveDir:Float;
  52. private var _idleTmr:Float;
  53. public var MaxSpeed:Float = 80;
  54.  
  55. public var _pA:FlxPoint;
  56. public var _pB:FlxPoint;
  57. public var _pC:FlxPoint;
  58. public var _pD:FlxPoint;
  59. public var _pE:FlxPoint;
  60. public var _pF:FlxPoint;
  61.  
  62. public var LoadedMap:Int;
  63.  
  64. public var TILEWIDTH:Float = 16;
  65. public var TILEHEIGHT:Float = 16;
  66.  
  67. public var tileCoordX:Float;
  68. public var tileCoordY:Float;
  69.  
  70. public var path:FlxPath;
  71. private var wandering:Bool;
  72. private var wanderTicks:Int;
  73. private var nodes:Array<FlxPoint>;
  74.  
  75. public var waitingTicks:Float;
  76.  
  77. //CONSTRUCTOR
  78. public function new(x:Float, y:Float, ThePlayer:Player, TheMap:FlxTilemap):Void
  79. {
  80. super(x, y);
  81.  
  82. //Set position
  83. loadGraphic(AssetPaths.Zombie__png , false, 22, 22);
  84.  
  85. _player = ThePlayer;
  86. _map = TheMap;
  87.  
  88. _idleTmr = 0;
  89.  
  90. waitingTicks = 2;
  91.  
  92. randCatch = Random.int(0, 5);
  93.  
  94. //Type Logic
  95. var TypeRoll:Int = 0;
  96.  
  97. TypeRoll = Random.int(0, 95);
  98.  
  99.  
  100. if (TypeRoll < 15)
  101. {
  102. SlimeClass = -1;
  103. loadGraphic(AssetPaths.Zombie__png , false, 22, 22);
  104. }
  105.  
  106. if (TypeRoll >= 15 && TypeRoll < 25) SlimeClass = 0;
  107. if (TypeRoll >= 25 && TypeRoll < 55) SlimeClass = 1;
  108. if (TypeRoll >= 56 && TypeRoll < 65) SlimeClass = 2;
  109. if (TypeRoll >= 66 && TypeRoll < 75) SlimeClass = 3;
  110. if (TypeRoll >= 76 && TypeRoll < 85) SlimeClass = 4;
  111. if (TypeRoll >= 86 && TypeRoll < 95) SlimeClass = 5;
  112.  
  113. //Green
  114. if (SlimeClass == 0)
  115. {
  116. loadGraphic("assets/images/SlimeGreen.png", false, 10, 9, false);
  117. }
  118.  
  119. //Blue
  120. if (SlimeClass == 1)
  121. {
  122. loadGraphic("assets/images/SlimeBlue.png", false, 10, 9,false);
  123. }
  124.  
  125. //Red
  126. if (SlimeClass == 2)
  127. {
  128. loadGraphic("assets/images/SlimeRed.png", false, 10, 9,false);
  129. }
  130.  
  131. //Purple
  132. if (SlimeClass == 3)
  133. {
  134. loadGraphic("assets/images/SlimePurple.png", false, 10, 9,false);
  135. }
  136. //Dark
  137. if (SlimeClass == 4)
  138. {
  139. loadGraphic("assets/images/SlimeDark.png", false, 10, 9,false);
  140. }
  141. //Imp
  142. if (SlimeClass == 5)
  143. {
  144. loadGraphic("assets/images/Impling.png", false, 16, 16,false);
  145. }
  146. //End Type Logic
  147.  
  148. solid = true;
  149.  
  150. health = 2;
  151.  
  152. collidesMap = false;
  153.  
  154. lastKnownX = _player.x;
  155. lastKnownY = _player.y;
  156.  
  157. _pA = new FlxPoint(lastKnownX, lastKnownY);
  158.  
  159. FlxVelocity.moveTowardsPoint(this, _pA, MaxSpeed);
  160.  
  161. //Loade nodes based on loaded stage
  162. if (LoadedMap == 1)
  163. {
  164. _pB = new FlxPoint(122, 108);
  165. _pC = new FlxPoint(86, 376);
  166. _pD = new FlxPoint(522, 322);
  167. _pE = new FlxPoint(530, 90);
  168. _pF = new FlxPoint(308, 222);
  169. }
  170.  
  171. elasticity = 1;
  172. }
  173.  
  174. override public function update():Void
  175. {
  176. //Lamp
  177. FlxSpriteUtil.screenWrap(this, true, true, true, true);
  178.  
  179. if (randCatch == 5 && !bonked)
  180. {
  181. SEEKER = true;
  182. FlxVelocity.moveTowardsObject(this, _player, Random.float(8, 38));
  183.  
  184. } else
  185. {
  186. SEEKER = true;
  187. }
  188.  
  189. super.update();
  190. }
  191.  
  192.  
  193. public function CollidesNow():Void
  194. {
  195. collidesMap = true;
  196. }
  197. }
Add Comment
Please, Sign In to add comment