Ejemplo n.º 1
0
        public Api_Result <Mem_ndock> Start(int rid, int ship_rid, bool highspeed)
        {
            Api_Result <Mem_ndock> api_Result = new Api_Result <Mem_ndock>();
            Mem_ndock value = null;

            if (!Comm_UserDatas.Instance.User_ndock.TryGetValue(rid, out value))
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            if (value.State != NdockStates.EMPTY)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            Mem_ship value2 = null;

            if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, out value2))
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            if (value2.IsBlingShip())
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            Dictionary <enumMaterialCategory, int> ndockMaterialNum = value2.GetNdockMaterialNum();

            if (ndockMaterialNum == null)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            int num = highspeed ? 1 : 0;

            if (ndockMaterialNum[enumMaterialCategory.Fuel] > Comm_UserDatas.Instance.User_material[enumMaterialCategory.Fuel].Value || ndockMaterialNum[enumMaterialCategory.Steel] > Comm_UserDatas.Instance.User_material[enumMaterialCategory.Steel].Value || num > Comm_UserDatas.Instance.User_material[enumMaterialCategory.Repair_Kit].Value)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            value2.BlingWaitToStop();
            if (!highspeed)
            {
                int ndockTimeSpan = value2.GetNdockTimeSpan();
                value.RecoverStart(ship_rid, ndockMaterialNum, ndockTimeSpan);
            }
            else
            {
                value.RecoverStart(ship_rid, ndockMaterialNum, 0);
                value.RecoverEnd(timeChk: false);
                Comm_UserDatas.Instance.User_material[enumMaterialCategory.Repair_Kit].Sub_Material(1);
            }
            api_Result.data = value;
            QuestSupply questSupply = new QuestSupply();

            questSupply.ExecuteCheck();
            return(api_Result);
        }
Ejemplo n.º 2
0
        public Api_Result <Mem_ndock> Start(int rid, int ship_rid, bool highspeed)
        {
            Api_Result <Mem_ndock> api_Result = new Api_Result <Mem_ndock>();
            Mem_ndock mem_ndock = null;

            if (!Comm_UserDatas.Instance.User_ndock.TryGetValue(rid, ref mem_ndock))
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            if (mem_ndock.State != NdockStates.EMPTY)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            Mem_ship mem_ship = null;

            if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, ref mem_ship))
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            if (mem_ship.IsBlingShip())
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            Dictionary <enumMaterialCategory, int> ndockMaterialNum = mem_ship.GetNdockMaterialNum();

            if (ndockMaterialNum == null)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            int num = (!highspeed) ? 0 : 1;

            if (ndockMaterialNum.get_Item(enumMaterialCategory.Fuel) > Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Fuel).Value || ndockMaterialNum.get_Item(enumMaterialCategory.Steel) > Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Steel).Value || num > Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Repair_Kit).Value)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            mem_ship.BlingWaitToStop();
            if (!highspeed)
            {
                int ndockTimeSpan = mem_ship.GetNdockTimeSpan();
                mem_ndock.RecoverStart(ship_rid, ndockMaterialNum, ndockTimeSpan);
            }
            else
            {
                mem_ndock.RecoverStart(ship_rid, ndockMaterialNum, 0);
                mem_ndock.RecoverEnd(false);
                Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Repair_Kit).Sub_Material(1);
            }
            api_Result.data = mem_ndock;
            QuestSupply questSupply = new QuestSupply();

            questSupply.ExecuteCheck();
            return(api_Result);
        }
        private void repairShipAutoRecovery(DeckShips deck)
        {
            int             num  = 86;
            int             num2 = 19;
            List <Mem_ship> list = deck.getMemShip();

            if (Enumerable.Count <Mem_ship>(list) == 0)
            {
                return;
            }
            if (list.get_Item(0).Stype != num2)
            {
                return;
            }
            DamageState damageState = list.get_Item(0).Get_DamageState();

            if (damageState == DamageState.Tyuuha || damageState == DamageState.Taiha)
            {
                return;
            }
            if (list.get_Item(0).ExistsNdock())
            {
                return;
            }
            if (list.get_Item(0).IsBlingShip())
            {
                return;
            }
            Mem_material mem_material  = Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Fuel);
            Mem_material mem_material2 = Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Steel);

            if (mem_material.Value == 0 && mem_material2.Value == 0)
            {
                return;
            }
            Mem_ship      arg_C7_0 = list.get_Item(0);
            HashSet <int> hashSet  = new HashSet <int>();

            hashSet.Add(num);
            Dictionary <int, int> mstSlotItemNum_OrderId = arg_C7_0.GetMstSlotItemNum_OrderId(hashSet);
            int num3 = mstSlotItemNum_OrderId.get_Item(num);

            list = Enumerable.ToList <Mem_ship>(Enumerable.Take <Mem_ship>(list, num3 + 2));
            using (List <Mem_ship> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Mem_ship current = enumerator.get_Current();
                    if (current.Nowhp < current.Maxhp)
                    {
                        DamageState damageState2 = current.Get_DamageState();
                        if (damageState2 != DamageState.Tyuuha && damageState2 != DamageState.Taiha)
                        {
                            if (!current.ExistsNdock())
                            {
                                if (!current.IsBlingShip())
                                {
                                    int    ndockTimeSpan = current.GetNdockTimeSpan();
                                    int    num4          = ndockTimeSpan * 30;
                                    int    num5          = 30;
                                    double num6          = (double)num5 / (double)num4;
                                    Dictionary <enumMaterialCategory, int> ndockMaterialNum = current.GetNdockMaterialNum();
                                    int num7 = (int)Math.Ceiling((double)ndockMaterialNum.get_Item(enumMaterialCategory.Fuel) * num6);
                                    int num8 = (int)Math.Ceiling((double)ndockMaterialNum.get_Item(enumMaterialCategory.Steel) * num6);
                                    if (mem_material.Value >= num7 && mem_material2.Value >= num8)
                                    {
                                        double num9  = (double)(current.Maxhp - current.Nowhp) * num6;
                                        int    num10 = (num9 >= 1.0) ? ((int)num9) : ((int)Math.Ceiling(num9));
                                        current.SubHp(-num10);
                                        mem_material.Sub_Material(num7);
                                        mem_material2.Sub_Material(num8);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }