Beispiel #1
0
        public static bool CanRoomUpdate(this HideOutRoom room, CHideOutRoomLevel hideoutroomlevel = null)
        {
            //if(!_room || !_btnUpgrade.visible || !User.current.character.hasTutorialFlag("hideout_first_attack"))
            //{
            //   _content.ui.upgradeAvailable.visible = false;
            //   return;
            //}
            //if (hideoutroomlevel == null)
            //{
            //    hideoutroomlevel = room.CNextLevel; // HzConstants.Default.Constants["hideout_rooms"][room.identifier]["levels"].OfType<JProperty>().FirstOrDefault(tok => tok.Name == (room.level + 1).ToString())?.Value; //CHideoutRoom.fromId(_room.identifier).getLevel(_room.level + 1);
            //}
            var _loc3_ = HzConstants.Default.Constants["hideout_room_upgrade"].OfType <JProperty>().FirstOrDefault(tok => tok.Name == (room.level + 1).ToString())?.Value["character_min_level"].Value <int>(); //CHideoutRoomUpgrade.fromId(_room.level + 1).characterMinLevel;

            if (_loc3_ > HzAccountManger.GetAccByHideOutID(room.hideout_id)?.Character?.level)
            {
                return(false);
            }
            else
            {
                if (room.CNextLevel != null &&
                    HzAccountManger.GetAccByHideOutID(room.hideout_id).Character?.game_currency >= room.CNextLevel.GetReducedGameCurrencyValue() &&
                    room.HideOut.current_resource_glue >= room.CNextLevel.price_glue &&
                    room.HideOut.current_resource_stone >= room.CNextLevel.price_stone)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        public static double CurrentCalculatedResourceAmount(this HideOutRoom room)
        {
            var _loc3_ = room.current_resource_amount;
            var _loc1_ = room.max_resource_amount;

            if (room.status != HideoutRoomStatus.Producing || _loc3_ >= _loc1_)
            {
                return(_loc3_);
            }
            if (room.CRoom.IsManuallyProductionRoom && room.ts_activity_end < HzAccountManger.GetAccByHideOutID(room.hideout_id).ServerTime)
            {
                return(_loc1_);
            }
            var _loc4_ = room.ts_last_resource_change;
            var _loc5_ = HzAccountManger.GetAccByHideOutID(room.hideout_id).ServerTime - _loc4_;
            var _loc6_ = Math.Floor(_loc5_ / 60.0f);

            if (_loc6_ <= 0)
            {
                return(_loc3_);
            }
            var _loc2_ = Math.Floor(ResourceAmountPerMinute(room) * _loc6_);

            return(Math.Min(_loc2_ + _loc3_, _loc1_));
        }
Beispiel #3
0
        public static double SecondsTillActivityFinished(this HideOutRoom room)
        {
            long   _loc3_ = 0;
            double _loc5_ = 0;
            var    _loc1_ = double.NaN;
            double _loc4_ = 0;
            double _loc2_ = 0;

            if (room.status == HideoutRoomStatus.Producing && !room.CRoom.IsManuallyProductionRoom)
            {
                _loc3_ = HzAccountManger.GetAccByHideOutID(room.hideout_id).ServerTime - room.ts_last_resource_change;
                _loc5_ = Math.Floor(_loc3_ / 60.0f);
                _loc1_ = ResourceAmountPerMinute(room);
                _loc4_ = Math.Floor(_loc1_ * _loc5_) + room.current_resource_amount;
                if (_loc4_ < room.max_resource_amount)
                {
                    _loc2_ = Math.Ceiling((room.max_resource_amount - _loc4_) / (_loc1_ / 60) - (_loc3_ - _loc5_ * 60));
                }
            }
            else if (room.status == HideoutRoomStatus.Upgrading ||
                     room.status == HideoutRoomStatus.Building ||
                     room.status == HideoutRoomStatus.Placing ||
                     room.status == HideoutRoomStatus.Storing ||
                     room.status == HideoutRoomStatus.Producing && room.CRoom.IsManuallyProductionRoom)
            {
                _loc2_ = room.ts_activity_end - HzAccountManger.GetAccByHideOutID(room.hideout_id).ServerTime;
            }
            return(_loc2_);
        }
Beispiel #4
0
 public static double MaxResourceAmount(this HideOutRoom room)
 {
     if (room.CRoom.IsAutoProductionRoom)
     {
         return(room.max_resource_amount * CurrentGeneratorFactor(room));
     }
     return(room.max_resource_amount);
 }
Beispiel #5
0
        public static double CurrentGeneratorFactor(this HideOutRoom room)
        {
            double _loc1_ = 1;

            if (room.CRoom.IsAutoProductionRoom && room.current_generator_level > 0)
            {
                _loc1_ = 1 + room.CGeneratator.passiv_bonus_amount_1 / 100.0f;
            }
            return(_loc1_);
        }
Beispiel #6
0
        public static HideoutWorkerActivity GetCurrentWorkerActivity(this HideOut hideout)
        {
            var         _loc4_  = 0;
            var         _loc7_  = 0;
            var         endTime = 0;
            HideOutRoom Room    = null;
            var         level   = -1;
            var         slot    = -1;

            foreach (var room in hideout.Rooms)
            {
                if (room.status == HideoutRoomStatus.Building || room.status == HideoutRoomStatus.Placing || room.status == HideoutRoomStatus.Storing || room.status == HideoutRoomStatus.Upgrading)
                {
                    if (room.ts_activity_end > endTime /* && room.ts_activity_end > HzAccountManger.GetAccByCharacterID(hideout.character_id).ServerTime*/)
                    {
                        endTime = room.ts_activity_end;
                        Room    = room;
                    }
                }
            }
            _loc4_ = 0;
            while (_loc4_ < HideoutUtil.MAX_LEVELS)
            {
                _loc7_ = 0;
                while (_loc7_ < HideoutUtil.MAX_SLOTS)
                {
                    if (hideout.IsSlotUnlockInProgress(_loc4_, _loc7_) && hideout.GetSlotUnlockTsEnd(_loc4_, _loc7_) > endTime /* && hideout.GetSlotUnlockTsEnd(_loc4_, _loc7_) > HzAccountManger.GetAccByCharacterID(hideout.character_id).ServerTime */)
                    {
                        endTime = hideout.GetSlotUnlockTsEnd(_loc4_, _loc7_);
                        level   = _loc4_;
                        slot    = _loc7_;
                    }
                    _loc7_++;
                }
                _loc4_++;
            }
            if (Room == null && level == -1 && slot == -1)
            {
                return(null);
            }
            return(new HideoutWorkerActivity(Room, level, slot, endTime));
        }
Beispiel #7
0
        public static double ResourceAmountPerMinute(this HideOutRoom room)
        {
            var    _loc3_ = Double.NaN;
            JToken _loc4_;
            double _loc2_ = 0;
            double _loc1_ = 0;

            if (room.CRoom.IsManuallyProductionRoom)
            {
                _loc3_ = (room.ts_activity_end - room.ts_last_resource_change) / (room.max_resource_amount - room.current_resource_amount);
                _loc1_ = 60 / _loc3_;
            }
            else if (room.CRoom.IsAutoProductionRoom)
            {
                _loc4_ = HzConstants.Default.Constants["hideout_rooms"][room.identifier]["levels"][room.level.ToString()];
                _loc2_ = Math.Max(Math.Round(_loc4_["min_till_max_resource"].Value <double>() * HzConstants.Default.Constants["hideout_min_till_max_resource_duration_scaling"].Value <double>()), 1);
                _loc1_ = room.max_resource_amount / _loc2_;
            }
            return(_loc1_);
        }
Beispiel #8
0
        public static bool IsRoomInStore(this HideOutRoom room)
        {
            var         level  = 0;
            var         slot   = 0;
            HideOutRoom _loc4_ = null;

            level = 0;
            while (level < HideoutUtil.MAX_LEVELS)
            {
                slot = 0;
                while (slot < HideoutUtil.MAX_SLOTS)
                {
                    _loc4_ = HzAccountManger.GetAccByHideOutID(room.hideout_id).Data.hideout.GetRoomBySlot(HideoutUtil.GetSlotIdFromLevelAndSlot(level, slot));
                    if (_loc4_ != null && _loc4_.id == room.id)
                    {
                        return(false);
                    }
                    slot++;
                }
                level++;
            }
            return(true);
        }
Beispiel #9
0
 public static async Task <string> PlaceHideoutRoomAsync(this HzPluginBase plugin, HideOutRoomSlot slot, HideOutRoom room)
 {
     return(await plugin.Account.DefaultRequestContent("placeHideoutRoom")
            .AddKeyValue("hideoutRoomId", room.id)
            .AddKeyValue("slot", slot.Slot)
            .AddKeyValue("level", slot.Level)
            .AddKeyValue("rct", "2")
            .AddLog($"[HideOut] Place Room {room.identifier}")
            .PostToHzAsync());
 }
Beispiel #10
0
 public static async Task <string> StoreHideoutRoomAsync(this HzPluginBase plugin, HideOutRoom room, bool ignoreResource = false)
 {
     return(await plugin.Account.DefaultRequestContent("storeHideoutRoom")
            .AddKeyValue("hideoutRoomId", room.id)
            .AddKeyValue("rct", "2")
            .AddKeyValue("ignoreResource", ignoreResource.ToString().ToLower())
            .AddLog($"[HideOut] Store Room {room.identifier}")
            .PostToHzAsync());
 }
Beispiel #11
0
 /// <summary>Checks the hideout room activity finished asynchronous.</summary>
 /// <param name="plugin">The plugin.</param>
 /// <param name="room">The room.</param>
 /// <returns></returns>
 public static async Task <string> CheckHideoutRoomActivityFinishedAsync(this HzPluginBase plugin, HideOutRoom room)
 {
     return(await plugin.Account.DefaultRequestContent("checkHideoutRoomActivityFinished")
            .AddKeyValue("hideout_room_id", room.id)
            .AddKeyValue("rct", "2")
            .AddLog($"[HideOut] Check For Complete")
            .PostToHzAsync());
 }
Beispiel #12
0
 /// <summary>Collects the hideout room activity result asynchronous.</summary>
 /// <param name="plugin">The plugin.</param>
 /// <param name="room">The hide our room.</param>
 /// <returns></returns>
 public static async Task <string> CollectHideoutRoomActivityResultAsync(this HzPluginBase plugin, HideOutRoom room)
 {
     return(await plugin.Account.DefaultRequestContent("collectHideoutRoomActivityResult")
            .AddKeyValue("hideout_room_id", room.id)
            .AddKeyValue("rct", "1")
            .AddLog($"[HideOut] Claim Reward:{room.id}")
            .PostToHzAsync());
 }
Beispiel #13
0
 public static bool HasRewardToCollect(this HideOutRoom room, int IsFullInProzent)
 {
     return(room.status == HideoutRoomStatus.Producing && room.CRoom.IsAutoProductionRoom && room.CurrentCalculatedResourceAmount() / room.MaxResourceAmount() * 100.0f >= IsFullInProzent);
 }