예제 #1
0
        public SlotSetChkResult_Slot IsValidSlotSet(int ship_rid, int slot_rid, int equip_idx)
        {
            if (this.IsValidSlotSet(ship_rid) != Api_req_Kaisou.SlotSetChkResult_Ship.Ok)
            {
                return(SlotSetChkResult_Slot.NgInvalid);
            }
            Mem_ship mem_ship = Comm_UserDatas.Instance.User_ship.get_Item(ship_rid);

            if (mem_ship.Slotnum < equip_idx + 1)
            {
                return(SlotSetChkResult_Slot.NgInvalid);
            }
            int num = mem_ship.Slot.FindIndex((int x) => x == -1);

            if (num != -1 && num < equip_idx)
            {
                equip_idx = num;
            }
            Mem_slotitem mem_slotitem = null;

            if (slot_rid != -1)
            {
                Comm_UserDatas.Instance.User_slot.TryGetValue(slot_rid, ref mem_slotitem);
                if (mem_slotitem == null)
                {
                    return(SlotSetChkResult_Slot.NgInvalid);
                }
                if (mem_slotitem.Equip_flag == Mem_slotitem.enumEquipSts.Equip)
                {
                    return(SlotSetChkResult_Slot.NgInvalid);
                }
            }
            else if (slot_rid == -1)
            {
                return(SlotSetChkResult_Slot.Ok);
            }
            int num2 = 0;
            int num3 = 0;
            OnslotChangeType slotChangeCost = Mst_slotitem_cost.GetSlotChangeCost(mem_ship.Slot.get_Item(equip_idx), slot_rid, out num2, out num3);
            int onslotKeisu = mem_ship.Onslot.get_Item(equip_idx);

            if (slotChangeCost == OnslotChangeType.OtherToPlane)
            {
                onslotKeisu = Mst_DataManager.Instance.Mst_ship.get_Item(mem_ship.Ship_id).Maxeq.get_Item(equip_idx);
            }
            int slotChangeBauxiteNum = Mst_slotitem_cost.GetSlotChangeBauxiteNum(slotChangeCost, num2, num3, onslotKeisu);

            if (slotChangeBauxiteNum > 0)
            {
                return(SlotSetChkResult_Slot.Ok);
            }
            if (Math.Abs(slotChangeBauxiteNum) > Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Value)
            {
                if (num2 == 0 && num3 > 0)
                {
                    return(SlotSetChkResult_Slot.NgBauxiteShort);
                }
                if (num2 < num3)
                {
                    return(SlotSetChkResult_Slot.NgBausiteShortHighCost);
                }
            }
            return(SlotSetChkResult_Slot.Ok);
        }
예제 #2
0
        public Api_Result <SlotSetChkResult_Slot> SlotSet(int ship_rid, int slot_rid, int equip_idx)
        {
            Api_Result <SlotSetChkResult_Slot> api_Result = new Api_Result <SlotSetChkResult_Slot>();
            SlotSetChkResult_Slot slotSetChkResult_Slot   = this.IsValidSlotSet(ship_rid, slot_rid, equip_idx);

            if (slotSetChkResult_Slot != SlotSetChkResult_Slot.Ok)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                api_Result.data  = slotSetChkResult_Slot;
                return(api_Result);
            }
            Mem_ship     mem_ship     = Comm_UserDatas.Instance.User_ship.get_Item(ship_rid);
            Mem_slotitem mem_slotitem = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(slot_rid, ref mem_slotitem);
            int num = mem_ship.Slot.FindIndex((int x) => x == -1);

            if (num != -1 && num < equip_idx)
            {
                equip_idx = num;
            }
            Mem_shipBase mem_shipBase  = new Mem_shipBase(mem_ship);
            Mem_slotitem mem_slotitem2 = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(mem_ship.Slot.get_Item(equip_idx), ref mem_slotitem2);
            int preCost   = 0;
            int afterCost = 0;
            OnslotChangeType slotChangeCost = Mst_slotitem_cost.GetSlotChangeCost(mem_ship.Slot.get_Item(equip_idx), slot_rid, out preCost, out afterCost);
            int num2 = mem_ship.Onslot.get_Item(equip_idx);

            if (slotChangeCost == OnslotChangeType.OtherToPlane)
            {
                num2 = Mst_DataManager.Instance.Mst_ship.get_Item(mem_ship.Ship_id).Maxeq.get_Item(equip_idx);
            }
            int slotChangeBauxiteNum = Mst_slotitem_cost.GetSlotChangeBauxiteNum(slotChangeCost, preCost, afterCost, num2);

            if (slotChangeBauxiteNum < 0)
            {
                if (slotChangeCost == OnslotChangeType.PlaneToPlane)
                {
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUseHighCost;
                }
                else if (slotChangeCost == OnslotChangeType.OtherToPlane)
                {
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUse;
                    mem_shipBase.Onslot.set_Item(equip_idx, num2);
                }
                Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Sub_Material(Math.Abs(slotChangeBauxiteNum));
            }
            else
            {
                if (slotChangeCost == OnslotChangeType.PlaneOther)
                {
                    mem_shipBase.Onslot.set_Item(equip_idx, 0);
                }
                api_Result.data = SlotSetChkResult_Slot.Ok;
                Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Add_Material(slotChangeBauxiteNum);
            }
            mem_shipBase.Slot.set_Item(equip_idx, slot_rid);
            if (mem_slotitem2 != null)
            {
                mem_slotitem2.UnEquip();
            }
            if (slot_rid != -1)
            {
                mem_slotitem.Equip(ship_rid);
            }
            mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship.get_Item(mem_shipBase.Ship_id), false);
            if (slot_rid == -1)
            {
                mem_ship.TrimSlot();
            }
            return(api_Result);
        }
예제 #3
0
        public SlotSetChkResult_Slot IsValidSlotSet(int ship_rid, int slot_rid, int equip_idx)
        {
            if (IsValidSlotSet(ship_rid) != 0)
            {
                return(SlotSetChkResult_Slot.NgInvalid);
            }
            Mem_ship mem_ship = Comm_UserDatas.Instance.User_ship[ship_rid];

            if (mem_ship.Slotnum < equip_idx + 1)
            {
                return(SlotSetChkResult_Slot.NgInvalid);
            }
            int num = mem_ship.Slot.FindIndex((int x) => x == -1);

            if (num != -1 && num < equip_idx)
            {
                equip_idx = num;
            }
            Mem_slotitem value = null;

            if (slot_rid != -1)
            {
                Comm_UserDatas.Instance.User_slot.TryGetValue(slot_rid, out value);
                if (value == null)
                {
                    return(SlotSetChkResult_Slot.NgInvalid);
                }
                if (value.Equip_flag == Mem_slotitem.enumEquipSts.Equip)
                {
                    return(SlotSetChkResult_Slot.NgInvalid);
                }
            }
            else if (slot_rid == -1)
            {
                return(SlotSetChkResult_Slot.Ok);
            }
            int preCost   = 0;
            int afterCost = 0;
            OnslotChangeType slotChangeCost = Mst_slotitem_cost.GetSlotChangeCost(mem_ship.Slot[equip_idx], slot_rid, out preCost, out afterCost);
            int onslotKeisu = mem_ship.Onslot[equip_idx];

            if (slotChangeCost == OnslotChangeType.OtherToPlane)
            {
                onslotKeisu = Mst_DataManager.Instance.Mst_ship[mem_ship.Ship_id].Maxeq[equip_idx];
            }
            int slotChangeBauxiteNum = Mst_slotitem_cost.GetSlotChangeBauxiteNum(slotChangeCost, preCost, afterCost, onslotKeisu);

            if (slotChangeBauxiteNum > 0)
            {
                return(SlotSetChkResult_Slot.Ok);
            }
            if (Math.Abs(slotChangeBauxiteNum) > Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Value)
            {
                if (preCost == 0 && afterCost > 0)
                {
                    return(SlotSetChkResult_Slot.NgBauxiteShort);
                }
                if (preCost < afterCost)
                {
                    return(SlotSetChkResult_Slot.NgBausiteShortHighCost);
                }
            }
            return(SlotSetChkResult_Slot.Ok);
        }
예제 #4
0
 public static int GetSlotChangeBauxiteNum(OnslotChangeType type, int preCost, int afterCost, int onslotKeisu)
 {
     return(0);
 }
예제 #5
0
        public Api_Result <SlotSetChkResult_Slot> SlotSet(int ship_rid, int slot_rid, int equip_idx)
        {
            Api_Result <SlotSetChkResult_Slot> api_Result = new Api_Result <SlotSetChkResult_Slot>();
            SlotSetChkResult_Slot slotSetChkResult_Slot   = IsValidSlotSet(ship_rid, slot_rid, equip_idx);

            if (slotSetChkResult_Slot != 0)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                api_Result.data  = slotSetChkResult_Slot;
                return(api_Result);
            }
            Mem_ship     mem_ship = Comm_UserDatas.Instance.User_ship[ship_rid];
            Mem_slotitem value    = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(slot_rid, out value);
            int num = mem_ship.Slot.FindIndex((int x) => x == -1);

            if (num != -1 && num < equip_idx)
            {
                equip_idx = num;
            }
            Mem_shipBase mem_shipBase = new Mem_shipBase(mem_ship);
            Mem_slotitem value2       = null;

            Comm_UserDatas.Instance.User_slot.TryGetValue(mem_ship.Slot[equip_idx], out value2);
            int preCost   = 0;
            int afterCost = 0;
            OnslotChangeType slotChangeCost = Mst_slotitem_cost.GetSlotChangeCost(mem_ship.Slot[equip_idx], slot_rid, out preCost, out afterCost);
            int num2 = mem_ship.Onslot[equip_idx];

            if (slotChangeCost == OnslotChangeType.OtherToPlane)
            {
                num2 = Mst_DataManager.Instance.Mst_ship[mem_ship.Ship_id].Maxeq[equip_idx];
            }
            int slotChangeBauxiteNum = Mst_slotitem_cost.GetSlotChangeBauxiteNum(slotChangeCost, preCost, afterCost, num2);

            if (slotChangeBauxiteNum < 0)
            {
                switch (slotChangeCost)
                {
                case OnslotChangeType.PlaneToPlane:
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUseHighCost;
                    break;

                case OnslotChangeType.OtherToPlane:
                    api_Result.data = SlotSetChkResult_Slot.OkBauxiteUse;
                    mem_shipBase.Onslot[equip_idx] = num2;
                    break;
                }
                Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Sub_Material(Math.Abs(slotChangeBauxiteNum));
            }
            else
            {
                if (slotChangeCost == OnslotChangeType.PlaneOther)
                {
                    mem_shipBase.Onslot[equip_idx] = 0;
                }
                api_Result.data = SlotSetChkResult_Slot.Ok;
                Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Add_Material(slotChangeBauxiteNum);
            }
            mem_shipBase.Slot[equip_idx] = slot_rid;
            value2?.UnEquip();
            if (slot_rid != -1)
            {
                value.Equip(ship_rid);
            }
            mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship[mem_shipBase.Ship_id], enemy_flag: false);
            if (slot_rid == -1)
            {
                mem_ship.TrimSlot();
            }
            return(api_Result);
        }