Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.ankamagames.dofus.internalDatacenter.quest
  2. {
  3.    import com.ankamagames.dofus.datacenter.npcs.Npc;
  4.    import com.ankamagames.dofus.datacenter.quest.treasureHunt.PointOfInterest;
  5.    import com.ankamagames.dofus.datacenter.world.Area;
  6.    import com.ankamagames.dofus.datacenter.world.MapPosition;
  7.    import com.ankamagames.dofus.datacenter.world.SubArea;
  8.    import com.ankamagames.dofus.datacenter.world.WorldMap;
  9.    import com.ankamagames.dofus.internalDatacenter.world.WorldPointWrapper;
  10.    import com.ankamagames.dofus.types.enums.TreasureHuntStepTypeEnum;
  11.    import com.ankamagames.jerakine.data.I18n;
  12.    import com.ankamagames.jerakine.interfaces.IDataCenter;
  13.    import com.ankamagames.jerakine.logger.Log;
  14.    import com.ankamagames.jerakine.logger.Logger;
  15.    import com.ankamagames.jerakine.types.enums.DirectionsEnum;
  16.    import com.ankamagames.jerakine.utils.pattern.PatternDecoder;
  17.    import flash.utils.getQualifiedClassName;
  18.    
  19.    public class TreasureHuntStepWrapper implements IDataCenter
  20.    {
  21.      
  22.       protected static const _log:Logger = Log.getLogger(getQualifiedClassName(TreasureHuntStepWrapper));
  23.        
  24.      
  25.       public var index:uint;
  26.      
  27.       public var type:uint;
  28.      
  29.       public var direction:int = -1;
  30.      
  31.       public var mapId:Number = -1;
  32.      
  33.       public var poiLabel:uint = 0;
  34.      
  35.       public var flagState:int = -1;
  36.      
  37.       public var count:uint = 0;
  38.      
  39.       private var _stepText:String;
  40.      
  41.       private var _stepRolloverText:String;
  42.      
  43.       public function TreasureHuntStepWrapper()
  44.       {
  45.          super();
  46.       }
  47.      
  48.       public static function create(type:uint, index:uint, direction:int, mapId:Number, poiLabel:uint, flagState:int = -1, count:uint = 0) : TreasureHuntStepWrapper
  49.       {
  50.          var item:TreasureHuntStepWrapper = new TreasureHuntStepWrapper();
  51.          item.type = type;
  52.          item.index = index;
  53.          item.direction = direction;
  54.          item.mapId = mapId;
  55.          item.poiLabel = poiLabel;
  56.          item.flagState = flagState;
  57.          item.count = count;
  58.          return item;
  59.       }
  60.      
  61.       public function get text() : String
  62.       {
  63.          var map:WorldPointWrapper = null;
  64.          var p:MapPosition = null;
  65.          var wm:WorldMap = null;
  66.          var poi:PointOfInterest = null;
  67.          var npc:Npc = null;
  68.          if(!this._stepText)
  69.          {
  70.             if(this.type == TreasureHuntStepTypeEnum.START)
  71.             {
  72.                map = new WorldPointWrapper(this.mapId);
  73.                this._stepText = I18n.getUiText("ui.common.start") + " [" + map.outdoorX + "," + map.outdoorY + "]";
  74.                p = MapPosition.getMapPositionById(this.mapId);
  75.                if(p && p.worldMap > 1)
  76.                {
  77.                   wm = WorldMap.getWorldMapById(p.worldMap);
  78.                   this._stepText = this._stepText + (!!wm?" " + wm.name:"");
  79.                }
  80.             }
  81.             else if(this.type == TreasureHuntStepTypeEnum.DIRECTION_TO_POI)
  82.             {
  83.                poi = PointOfInterest.getPointOfInterestById(this.poiLabel);
  84.                if(poi)
  85.                {
  86.                   this._stepText = poi.name;
  87.                }
  88.                else
  89.                {
  90.                   this._stepText = "???";
  91.                }
  92.             }
  93.             else if(this.type == TreasureHuntStepTypeEnum.DIRECTION)
  94.             {
  95.                this._stepText = "x" + this.count;
  96.             }
  97.             else if(this.type == TreasureHuntStepTypeEnum.DIRECTION_TO_HINT)
  98.             {
  99.                npc = Npc.getNpcById(this.count);
  100.                this._stepText = npc.name;
  101.             }
  102.             else if(this.type == TreasureHuntStepTypeEnum.FIGHT)
  103.             {
  104.                this._stepText = "";
  105.             }
  106.             else if(this.type == TreasureHuntStepTypeEnum.UNKNOWN)
  107.             {
  108.                this._stepText = "?";
  109.             }
  110.          }
  111.          return this._stepText;
  112.       }
  113.      
  114.       public function get overText() : String
  115.       {
  116.          var directionName:String = null;
  117.          var subArea:SubArea = null;
  118.          var area:Area = null;
  119.          if(!this._stepRolloverText)
  120.          {
  121.             if(this.type == TreasureHuntStepTypeEnum.START)
  122.             {
  123.                subArea = SubArea.getSubAreaByMapId(this.mapId);
  124.                if(subArea)
  125.                {
  126.                   area = subArea.area;
  127.                   if(area)
  128.                   {
  129.                      this._stepRolloverText = area.name + " (" + subArea.name + ")";
  130.                   }
  131.                }
  132.             }
  133.             else if(this.type == TreasureHuntStepTypeEnum.DIRECTION_TO_POI || this.type == TreasureHuntStepTypeEnum.DIRECTION_TO_HINT)
  134.             {
  135.                if(this.direction == DirectionsEnum.RIGHT)
  136.                {
  137.                   directionName = I18n.getUiText("ui.treasureHunt.theEast");
  138.                }
  139.                else if(this.direction == DirectionsEnum.DOWN)
  140.                {
  141.                   directionName = I18n.getUiText("ui.treasureHunt.theSouth");
  142.                }
  143.                else if(this.direction == DirectionsEnum.LEFT)
  144.                {
  145.                   directionName = I18n.getUiText("ui.treasureHunt.theWest");
  146.                }
  147.                else if(this.direction == DirectionsEnum.UP)
  148.                {
  149.                   directionName = I18n.getUiText("ui.treasureHunt.theNorth");
  150.                }
  151.                else if(this.direction == DirectionsEnum.DOWN_LEFT)
  152.                {
  153.                   directionName = I18n.getUiText("ui.treasureHunt.theSouthWest");
  154.                }
  155.                else if(this.direction == DirectionsEnum.DOWN_RIGHT)
  156.                {
  157.                   directionName = I18n.getUiText("ui.treasureHunt.theSouthEast");
  158.                }
  159.                else if(this.direction == DirectionsEnum.UP_LEFT)
  160.                {
  161.                   directionName = I18n.getUiText("ui.treasureHunt.theNorthWest");
  162.                }
  163.                else if(this.direction == DirectionsEnum.UP_RIGHT)
  164.                {
  165.                   directionName = I18n.getUiText("ui.treasureHunt.theNorthEast");
  166.                }
  167.                this._stepRolloverText = I18n.getUiText("ui.treasureHunt.followDirectionToPOI",[directionName,"[" + this._stepText + "]"]);
  168.             }
  169.             else if(this.type == TreasureHuntStepTypeEnum.DIRECTION)
  170.             {
  171.                if(this.direction == DirectionsEnum.RIGHT)
  172.                {
  173.                   directionName = I18n.getUiText("ui.treasureHunt.theEast");
  174.                }
  175.                else if(this.direction == DirectionsEnum.DOWN)
  176.                {
  177.                   directionName = I18n.getUiText("ui.treasureHunt.theSouth");
  178.                }
  179.                else if(this.direction == DirectionsEnum.LEFT)
  180.                {
  181.                   directionName = I18n.getUiText("ui.treasureHunt.theWest");
  182.                }
  183.                else if(this.direction == DirectionsEnum.UP)
  184.                {
  185.                   directionName = I18n.getUiText("ui.treasureHunt.theNorth");
  186.                }
  187.                else if(this.direction == DirectionsEnum.DOWN_LEFT)
  188.                {
  189.                   directionName = I18n.getUiText("ui.treasureHunt.theSouthWest");
  190.                }
  191.                else if(this.direction == DirectionsEnum.DOWN_RIGHT)
  192.                {
  193.                   directionName = I18n.getUiText("ui.treasureHunt.theSouthEast");
  194.                }
  195.                else if(this.direction == DirectionsEnum.UP_LEFT)
  196.                {
  197.                   directionName = I18n.getUiText("ui.treasureHunt.theNorthWest");
  198.                }
  199.                else if(this.direction == DirectionsEnum.UP_RIGHT)
  200.                {
  201.                   directionName = I18n.getUiText("ui.treasureHunt.theNorthEast");
  202.                }
  203.                this._stepRolloverText = PatternDecoder.combine(I18n.getUiText("ui.treasureHunt.followDirection",[this.count,directionName]),"n",this.count <= 1);
  204.             }
  205.          }
  206.          return this._stepRolloverText;
  207.       }
  208.      
  209.       public function update(type:uint, index:uint, direction:int, mapId:Number, poiLabel:uint, flagState:int = -1, count:uint = 0) : void
  210.       {
  211.          this.type = type;
  212.          this.index = index;
  213.          this.direction = direction;
  214.          this.mapId = mapId;
  215.          this.poiLabel = poiLabel;
  216.          this.flagState = flagState;
  217.          this.count = count;
  218.       }
  219.    }
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement