public Api_Result <SlotSetChkResult_Slot> SlotSet(int ship_rid, int slot_rid) { Api_Result <SlotSetChkResult_Slot> api_Result = new Api_Result <SlotSetChkResult_Slot>(); SlotSetChkResult_Slot slotSetChkResult_Slot = this.IsValidSlotSet(ship_rid, slot_rid); 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); Mem_shipBase mem_shipBase = new Mem_shipBase(mem_ship); Mem_slotitem mem_slotitem2 = null; Comm_UserDatas.Instance.User_slot.TryGetValue(mem_ship.Exslot, ref mem_slotitem2); mem_shipBase.Exslot = 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); return(api_Result); }
public Api_Result <Hashtable> Unslot_all(int ship_rid) { Api_Result <Hashtable> result = new Api_Result <Hashtable>(); Mem_ship mem_ship = Comm_UserDatas.Instance.User_ship.get_Item(ship_rid); Mem_shipBase mem_shipBase = new Mem_shipBase(mem_ship); for (int i = 0; i < Enumerable.Count <int>(mem_shipBase.Slot); i++) { Mem_slotitem mem_slotitem = null; int num = mem_shipBase.Slot.get_Item(i); mem_shipBase.Slot.set_Item(i, -1); if (num > 0 && Comm_UserDatas.Instance.User_slot.TryGetValue(num, ref mem_slotitem)) { Mst_slotitem_cost mst_slotitem_cost = null; if (Mst_DataManager.Instance.Mst_slotitem_cost.TryGetValue(mem_slotitem.Slotitem_id, ref mst_slotitem_cost)) { int addNum = mst_slotitem_cost.GetAddNum(mem_shipBase.Onslot.get_Item(i)); Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Bauxite).Add_Material(addNum); } mem_slotitem.UnEquip(); } } mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship.get_Item(mem_shipBase.Ship_id), false); mem_ship.TrimSlot(); return(result); }
public Api_Result <SlotSetChkResult_Slot> SlotSet(int ship_rid, int slot_rid) { Api_Result <SlotSetChkResult_Slot> api_Result = new Api_Result <SlotSetChkResult_Slot>(); SlotSetChkResult_Slot slotSetChkResult_Slot = IsValidSlotSet(ship_rid, slot_rid); 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); Mem_shipBase mem_shipBase = new Mem_shipBase(mem_ship); Mem_slotitem value2 = null; Comm_UserDatas.Instance.User_slot.TryGetValue(mem_ship.Exslot, out value2); mem_shipBase.Exslot = 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); return(api_Result); }
public Api_Result <Hashtable> Unslot_all(int ship_rid) { Api_Result <Hashtable> result = new Api_Result <Hashtable>(); Mem_ship mem_ship = Comm_UserDatas.Instance.User_ship[ship_rid]; Mem_shipBase mem_shipBase = new Mem_shipBase(mem_ship); for (int i = 0; i < mem_shipBase.Slot.Count(); i++) { Mem_slotitem value = null; int num = mem_shipBase.Slot[i]; mem_shipBase.Slot[i] = -1; if (num > 0 && Comm_UserDatas.Instance.User_slot.TryGetValue(num, out value)) { Mst_slotitem_cost value2 = null; if (Mst_DataManager.Instance.Mst_slotitem_cost.TryGetValue(value.Slotitem_id, out value2)) { int addNum = value2.GetAddNum(mem_shipBase.Onslot[i]); Comm_UserDatas.Instance.User_material[enumMaterialCategory.Bauxite].Add_Material(addNum); } value.UnEquip(); } } mem_ship.Set_ShipParam(mem_shipBase, Mst_DataManager.Instance.Mst_ship[mem_shipBase.Ship_id], enemy_flag: false); mem_ship.TrimSlot(); return(result); }
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); }
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); }