Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.Event;
  2. import com.whirled.AvatarControl;
  3. import com.whirled.ControlEvent;
  4. import com.whirled.EntityControl;
  5.  
  6. if (_ctrl == null) {
  7.     _ctrl = new AvatarControl(this);
  8.     _ctrl.setHotSpot(300, 370, 250);
  9.     _body = new Body(_ctrl,this,600);
  10.     addEventListener(Event.UNLOAD, handleUnload);
  11.     _ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, handleAction);
  12.     _ctrl.addEventListener(ControlEvent.STATE_CHANGED, handleState);
  13.     function handleUnload(... ignored):void {
  14.         timer.stop();
  15.         timer.removeEventListener(TimerEvent.TIMER, timeCount);
  16.         _body.shutdown();
  17.     }
  18. }
  19. // RankUp and LevelPopup //
  20. function timeCount(e:TimerEvent):void {
  21.     _popup.timeSeconds.text = String(timer.currentCount +prevCount);
  22.     if (timer.currentCount + prevCount >= 30) {
  23.         if (timer.currentCount + prevCount == 30) { // If the total is exactly 30, means you just levelled up.
  24.             _ctrl.showPopup("Levelled Up!", _levelup as DisplayObject, _levelup.width, _levelup.height);
  25.         }
  26.         _popup.rank.gotoAndStop(2);
  27.     }
  28.     if (timer.currentCount + prevCount >= 100) {
  29.         if (timer.currentCount + prevCount == 100) { // If the total is exactly 100, means you just levelled up.
  30.             _ctrl.showPopup("Levelled Up!", _levelup as DisplayObject, _levelup.width, _levelup.height);
  31.         }
  32.         _popup.rank.gotoAndStop(3);
  33.     }
  34.     _ctrl.setMemory("timerCount", timer.currentCount + prevCount);
  35. }
  36. // RankUp and LevelPopup END //
  37.  
  38. // Rank Action
  39. function handleAction(e:ControlEvent):void {
  40.     switch (e.name) {
  41.         case "Rank" :
  42.             _ctrl.showPopup("Ranks", _popup as DisplayObject, _popup.width, _popup.height);
  43.             break;
  44.     }
  45. }
  46.  
  47. //Register actions for states //
  48. function handleState(o:Object = null):void {
  49.     _ctrl.registerStates(getStateInfo());
  50.     switch (_ctrl.getState()) {
  51.         case "UMP" :
  52.             _ctrl.registerActions("UMP Fire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
  53.             break;
  54.         case "Secondary" :
  55.             _ctrl.registerActions("SFire", "Toggle Outline ON", "Toggle Outline OFF", "Rank");
  56.             break;
  57.         case "Default" :
  58.             _ctrl.registerActions("Toggle Outline ON", "Toggle Outline OFF", "Rank");
  59.             break;
  60.     }
  61. }
  62.  
  63. // Change states based on level //
  64. function getStateInfo():Array {
  65.     var stateArray:Array = new Array();
  66.     stateArray.push("UMP");
  67.     if (timer.currentCount + prevCount >= 100) {
  68.         stateArray.push("Secondary", "Default");
  69.     }
  70.     return stateArray;
  71. }
  72.  
  73. var _popup:Popup = new Popup();
  74. var _levelup:LevelUp = new LevelUp(); // The Popup you want to fire when someone Levels Up.
  75.  
  76. var timer:Timer = new Timer(1000, 0);
  77.     timer.addEventListener(TimerEvent.TIMER, timeCount);
  78.     timer.start();
  79.    
  80. var prevCount:Number = Number(_ctrl.getMemory("timerCount", 0));
  81.  
  82. var _ctrl:AvatarControl;
  83. var _body:Body;
  84. var dlsa:DuelingLandSeaAnimal = new DuelingLandSeaAnimal(_ctrl, ["PrimaryB","SecondaryB", "MeleeB", "RPGB", "GrenadeB"], ["PFire Battle","SFire Battle", "MeleeB", "RFire Battle", "GThrow Battle"], ["Dead"]);
  85.  
  86. handleState();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement