public void ParseInfo(Hashtable info) { mRaw = info; id = info.GetValue <string>((int)SPC.Id, string.Empty); //1 type = info.GetValue <byte>((int)SPC.Type, (byte)ShipModelSlotType.CB).toEnum <ShipModelSlotType>(); //2 level = info.GetValue <int>((int)SPC.Level, 0); //3 name = info.GetValue <string>((int)SPC.Name, string.Empty); //4 workshop = info.GetValue <byte>((int)SPC.Workshop, (byte)Workshop.DarthTribe).toEnum <Workshop>(); //5 set = info.GetValue <string>((int)SPC.Set, string.Empty); //6 skill = info.GetValue <int>((int)SPC.Skill, -1); //8 hp = info.GetValue <float>((int)SPC.Health, 0.0f); //9 speed = info.GetValue <float>((int)SPC.Speed, 0.0f); //10 resist = info.GetValue <float>((int)SPC.Resist, 0.0f); //11 hold = info.GetValue <int>((int)SPC.Hold, 0); //12 damageBonus = info.GetValue <float>((int)SPC.DamageBonus, 0.0f); //13 color = info.GetValue <byte>((int)SPC.Color, (byte)ObjectColor.white).toEnum <ObjectColor>(); //16 templateId = info.GetValue <string>((int)SPC.Template, string.Empty); //17 prefab = info.GetValue <string>((int)SPC.Prefab, string.Empty); //18 critChance = info.GetValue <float>((int)SPC.CritChance, 0.0f); //19 critDamage = info.GetValue <float>((int)SPC.CritDamage, 0.0f); //20 energyBonus = info.GetValue <float>((int)SPC.EnergyBonus, 0f); speedBonus = info.GetValue <float>((int)SPC.SpeedBonus, 0f); holdBonus = info.GetValue <float>((int)SPC.HoldBonus, 0f); Hashtable craftMaterialsHash = info.GetValue <Hashtable>((int)SPC.CraftMaterials, new Hashtable()); this.craftMaterials = craftMaterialsHash.toDict <string, int>(); //23 binded = info.GetValue <bool>((int)SPC.Binded, false); }
protected override void GenerateModule(DropManager dropManager, ShipModelSlotType slotType) { //base.GenerateModule(dropManager, slotType); bool success = false; if (m_Data != null) { if (m_Data.moduleList.ContainsKey(slotType)) { ModuleGenList gen; if (m_Data.moduleList.TryGetValue(slotType, out gen)) { ShipModule prevModule; ShipModule module = new ShipModule(gen); shipModel.SetModule(module, out prevModule); success = true; s_Log.InfoFormat("Special Ship {0} generate success".Magenta(), slotType); } } else { s_Log.InfoFormat("Special Ship data module list invalid".Magenta()); } } else { s_Log.Info("Special Ship data is null".Magenta()); } if (!success) { base.GenerateModule(dropManager, slotType); } }
public ShipModule(ModuleGenList gen) { this.id = gen.id; this.slotType = gen.slot; this.level = gen.level; this.name = gen.name; this.workshop = gen.workshop; this.templateModuleId = gen.dataId; this.craftMaterials = new Dictionary <string, int>(); foreach (var di in gen.deconstructOre) { this.craftMaterials.Add(di.id, di.count); } this.difficulty = gen.difficulty; this.color = gen.color; this.prefab = gen.model; this.hp = gen.hp; this.speed = gen.speed; this.hold = gen.hold; this.critDamage = gen.critDamage; SetCommonResist(gen.resist); this.damageBonus = gen.damageBonus; this.energyBonus = gen.energyBonus; this.critChance = gen.critChance; this.speedBonus = gen.speedBonus; this.holdBonus = gen.holdBonus; this.skillId = gen.skill; this.set = gen.setId; var dump = GetInfo(); }
public ShipModule Module(ShipModelSlotType type) { if (Slot(type) != null) { return(Slot(type).Module); } return(null); }
public ModuleSkillLeveling GetModuleSkills(ShipModelSlotType slotType) { if (moduleSkills.ContainsKey(slotType)) { return(moduleSkills[slotType]); } return(null); }
public bool HasModule(ShipModelSlotType type) { if (Slot(type) != null) { return(Slot(type).HasModule); } return(false); }
public ModuleInfo Module(Workshop workshop, ShipModelSlotType type, string id) { List <ModuleInfo> filteredModules = null; if (this.modules.TryGetValue(workshop, out filteredModules)) { return(filteredModules.Where(m => m.Id == id && m.Type == type).FirstOrDefault()); } return(null); }
public int[] AllowedSkills(Workshop workshop, ShipModelSlotType slotType, int level) { Dictionary <ShipModelSlotType, Dictionary <int, int[]> > filtered = null; if (skills.TryGetValue(workshop, out filtered)) { return(AllowedSkills(filtered, slotType, level)); } return(new int[] { }); }
public List <ModuleInfo> ModulesWithSet(Workshop workshop, ShipModelSlotType type) { List <ModuleInfo> filteredModules = null; if (modules.TryGetValue(workshop, out filteredModules)) { return(filteredModules.Where(m => m.hasSets && m.Type == type).ToList()); } return(new List <ModuleInfo>()); }
public bool Contains(int level, ShipModelSlotType slotType) { foreach (var m in materials) { if (m.level == level && m.slotType == slotType) { return(true); } } return(false); }
public StartPlayerWorkshopModel(UniXMLElement parent) { workshop = (Workshop)System.Enum.Parse(typeof(Workshop), parent.GetString("id")); model = new Dictionary <ShipModelSlotType, string>(); var dump = parent.Elements("module").Select(e => { ShipModelSlotType type = (ShipModelSlotType)Enum.Parse(typeof(ShipModelSlotType), e.GetString("type")); string id = e.GetString("id"); model.Add(type, id); return(type); }).ToList(); }
public void MasterUpdateShipModule(string gameRefID, string characterID, ShipModelSlotType slotType, string templateID) { UpdateShipModel op = new UpdateShipModel { CharacterId = characterID, GameRefId = gameRefID, SlotType = (byte)slotType, TemplateId = templateID }; OperationRequest request = new OperationRequest((byte)ServerToServerOperationCode.UpdateShipModel, op); this.MasterPeer.SendOperationRequest(request, new SendParameters()); }
public ShipModule(ShipModelSlotType slotType, string id, int level, string name, Workshop workshop, string templateModuleId, Dictionary <string, int> craftMaterials, Difficulty difficulty) { this.slotType = slotType; this.id = id; this.level = level; this.name = name; this.workshop = workshop; this.templateModuleId = templateModuleId; this.craftMaterials = craftMaterials; this.difficulty = difficulty; isNew = true; }
public ModuleInfo Module(Workshop workshop, ShipModelSlotType type) { List <ModuleInfo> filteredModules = null; if (this.modules.TryGetValue(workshop, out filteredModules)) { List <ModuleInfo> modules = filteredModules.Where(m => m.Type == type).ToList(); if (modules.Count > 0) { return(modules.AnyElement()); } } return(null); }
public ModuleSlotSettingData(XElement element) { m_SlotType = (ShipModelSlotType)Enum.Parse(typeof(ShipModelSlotType), element.GetString("type")); m_Hp = new BaseParam(element.Element("hp")); m_Speed = new BaseParam(element.Element("speed")); m_Cargo = new BaseParam(element.Element("cargo")); m_Resist = new AddParam(element.Element("resist")); m_DamageBonus = new AddParam(element.Element("damage_bonus")); m_CargoBonus = new AddParam(element.Element("cargo_bonus")); m_EnergyBonus = new AddParam(element.Element("energy_bonus")); m_SpeedBonus = new AddParam(element.Element("speed_bonus")); m_CritChanceBonus = new AddParam(element.Element("crit_chance")); m_CritDamageBonus = new AddParam(element.Element("crit_damage")); }
public ModuleInfo RandomModule(Workshop workshop, ShipModelSlotType type) { List <ModuleInfo> filteredModules = null; if (this.modules.TryGetValue(workshop, out filteredModules)) { List <ModuleInfo> typedModules = filteredModules.Where(m => m.Type == type).ToList(); if (typedModules.Count > 0) { return(typedModules[Rand.Int(typedModules.Count - 1)]); } } return(null); }
public ModuleDropParams(IRes resource, string inTemplateID, int level, Difficulty difficulty, Dictionary <string, int> incraftingMaterials, ObjectColor color, string set) { this.resource = resource; this.level = level; this.difficulty = difficulty; this.craftingMaterials = incraftingMaterials; templateID = inTemplateID; useTemplateID = true; moduleInfo = resource.ModuleTemplates.Module(templateID); slotType = moduleInfo.Type; workshop = moduleInfo.Workshop; this.color = color; this.set = set; }
public bool RemoveModule(ShipModelSlotType type, out ShipModule prevModule) { prevModule = null; if (Slot(type) != null) { Slot(type).RemoveModule(out prevModule); } sets.UpdateSets(this.slots); if (prevModule != null) { return(true); } else { return(false); } }
public Dictionary <string, int> GetCraftingMaterials(int level, ShipModelSlotType slotType, ObjectColor objColor) { Dictionary <string, int> result = new Dictionary <string, int>(); foreach (var m in materials) { if (m.level == level && m.slotType == slotType) { foreach (var p in m.craftingMaterials) { result.Add(p.Key, p.Value + AddForColor(objColor)); } return(result); } } return(result); }
public ClientShipModelSlot Slot(ShipModelSlotType type) { switch (type) { case ShipModelSlotType.CB: return(cb); case ShipModelSlotType.CM: return(cm); case ShipModelSlotType.DF: return(df); case ShipModelSlotType.DM: return(dm); case ShipModelSlotType.ES: return(es); default: return(null); } }
protected virtual void GenerateModule(DropManager dropManager, ShipModelSlotType slotType) { ModuleDropper moduleDropper = null; ShipModule prevModule = null; var CB = resource.ModuleTemplates.RandomModule((Workshop)mCharacter.workshop, slotType); var CBParams = new ModuleDropper.ModuleDropParams( resource, CB.Id, mCharacter.level, mDifficulty, new Dictionary <string, int>(), ObjectColor.white, string.Empty ); moduleDropper = dropManager.GetModuleDropper(CBParams); shipModel.SetModule(moduleDropper.Drop() as ShipModule, out prevModule); }
public ModuleDropParams( IRes resource, Workshop inWorkshop, ShipModelSlotType inSlotType, int level, Difficulty difficulty, Dictionary <string, int> incraftingMaterials, ObjectColor color, string set) { this.resource = resource; this.level = level; this.difficulty = difficulty; this.craftingMaterials = incraftingMaterials; workshop = inWorkshop; slotType = inSlotType; this.color = color; this.set = set; }
private KeyValuePair <Workshop, Dictionary <ShipModelSlotType, Dictionary <int, int[]> > > LoadForWorkshop(Workshop workshop, XDocument document) { var skillsDICT = document.Element("skill_dropping").Elements("slot").Select(slotElement => { ShipModelSlotType slotType = (ShipModelSlotType)Enum.Parse(typeof(ShipModelSlotType), slotElement.GetString("slot_type")); Dictionary <int, int[]> levelSkills = slotElement.Elements("level").Select(levelElement => { int level = levelElement.GetInt("value"); string[] asSkills = levelElement.GetString("skills").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int[] aiSkills = new int[asSkills.Length]; for (int i = 0; i < asSkills.Length; i++) { aiSkills[i] = int.Parse(asSkills[i], System.Globalization.NumberStyles.HexNumber); } return(new { LEVEL = level, SKILLS = aiSkills }); }).ToDictionary(obj => obj.LEVEL, obj => obj.SKILLS); return(new { SLOTTYPE = slotType, LEVELSKILLS = levelSkills }); }).ToDictionary(obj => obj.SLOTTYPE, obj => obj.LEVELSKILLS); return(new KeyValuePair <Workshop, Dictionary <ShipModelSlotType, Dictionary <int, int[]> > >(workshop, skillsDICT)); }
private ShipModule CreateModule(int workshop, int level, ShipModelSlotType slotType) { ColorInfo color = application.resource.ColorRes.GenColor(Space.Game.Resources.ColoredObjectType.Module, 1); string setid = string.Empty; if (color.color == ObjectColor.green) { var allSets = application.resource.Sets.WorkshopSets((Workshop)(byte)workshop, level); if (allSets.Count > 0) { setid = allSets[Rand.Int(0, allSets.Count - 1)].Id; } } ModuleDropper mdropper = new ModuleDropper(new ModuleDropper.ModuleDropParams(application.resource, (Workshop)(byte)workshop, slotType, level, Difficulty.none, new Dictionary <string, int>(), color.color, setid)); return(mdropper.DropModule()); }
public void UpdateShipModel(string gameRefID, string characterID, ShipModelSlotType slotType, string templateID) { DbObjectWrapper <DbPlayerCharactersObject> wrapper = null; lock (syncObject) { if (TryGetValue(gameRefID, out wrapper)) { if (wrapper.Data.SelectedCharacterId == characterID) { var character = wrapper.Data.GetCharacter(characterID); if (character != null) { character.SetModule((byte)slotType, templateID); wrapper.Changed = true; } } } } }
public bool LoadFromFile(string fullPath) { XDocument document = XDocument.Load(fullPath); this.modules = document.Element("races").Elements("race").Select(re => { Race race = (Race)Enum.Parse(typeof(Race), re.GetString("id")); Dictionary <Workshop, Dictionary <ShipModelSlotType, string> > workshopsDict = re.Element("workshops").Elements("workshop").Select(we => { Workshop workshop = (Workshop)Enum.Parse(typeof(Workshop), we.GetString("id")); Dictionary <ShipModelSlotType, string> modulesDict = we.Elements("module").Select(me => { ShipModelSlotType t = (ShipModelSlotType)Enum.Parse(typeof(ShipModelSlotType), me.GetString("type")); string id = me.GetString("id"); return(new { TYPE = t, ID = id }); }).ToDictionary(o => o.TYPE, o => o.ID); return(new { KEY = workshop, VALUE = modulesDict }); }).ToDictionary(o2 => o2.KEY, o2 => o2.VALUE); return(new { RESKEY = race, RESVALUE = workshopsDict }); }).ToDictionary(o3 => o3.RESKEY, o3 => o3.RESVALUE); this.loaded = true; return(this.loaded); }
public void ParseInfo(Hashtable info) { mRaw = info; this.id = info.GetValue <string>((int)SPC.Id, string.Empty); this.slotType = (ShipModelSlotType)(byte)info.GetValue <int>((int)SPC.Type, (int)ShipModelSlotType.CB.toByte()); this.level = info.GetValue <int>((int)SPC.Level, 0); this.name = info.GetValue <string>((int)SPC.Name, string.Empty); this.workshop = (Workshop)(byte)info.GetValue <int>((int)SPC.Workshop, (int)Workshop.DarthTribe.toByte()); this.templateModuleId = info.GetValue <string>((int)SPC.Template, string.Empty); this.color = (ObjectColor)(int)info.GetValue <int>((int)SPC.Color, (int)ObjectColor.white.toByte()); this.hp = info.GetValue <float>((int)SPC.Health, 0); this.speed = info.GetValue <float>((int)SPC.Speed, 0); this.hold = info.GetValue <int>((int)SPC.Hold, 0); //this.resist = info.GetValue<float>((int)SPC.Resist, 0); m_Resist.SetCommonResist(info.GetValue <float>((int)SPC.Resist, 0.0f)); m_Resist.SetAcidResist(info.GetValue <float>((int)SPC.AcidResist, 0.0f)); m_Resist.SetLaserResist(info.GetValue <float>((int)SPC.LaserResist, 0.0f)); m_Resist.SetRocketResist(info.GetValue <float>((int)SPC.RocketResist, 0.0f)); this.damageBonus = info.GetValue <float>((int)SPC.DamageBonus, 0); energyBonus = info.GetValue <float>((int)SPC.EnergyBonus, 0); this.critChance = info.GetValue <float>((int)SPC.CritChance, 0); this.critDamage = info.GetValue <float>((int)SPC.CritDamage, 0); speedBonus = info.GetValue <float>((int)SPC.SpeedBonus, 0); holdBonus = info.GetValue <float>((int)SPC.HoldBonus, 0); Hashtable craftMaterialsHash = info.GetValue <Hashtable>((int)SPC.CraftMaterials, new Hashtable()); this.craftMaterials = craftMaterialsHash.toDict <string, int>(); this.difficulty = (Difficulty)(byte)info.GetValue <int>((int)SPC.Difficulty, 0); this.prefab = info.GetValue <string>((int)SPC.Prefab, string.Empty); this.skillId = info.GetValue <int>((int)SPC.Skill, -1); this.set = info.GetValue <string>((int)SPC.Set, string.Empty); binded = info.GetValue <bool>((int)SPC.Binded, binded); isNew = info.GetValue <bool>((int)SPC.IsNew, isNew); }
public void ParseInfo(Hashtable info) { mRaw = info; if (mRaw == null) { return; } id = info.GetValueString((int)SPC.Id); //1 type = info.GetValueByte((int)SPC.Type, (byte)ShipModelSlotType.CB).toEnum <ShipModelSlotType>(); //2 level = info.GetValueInt((int)SPC.Level, 0); //3 name = info.GetValueString((int)SPC.Name); //4 workshop = info.GetValueByte((int)SPC.Workshop, (byte)Workshop.DarthTribe).toEnum <Workshop>(); //5 set = info.GetValueString((int)SPC.Set); //6 skill = info.GetValueInt((int)SPC.Skill, -1); //8 hp = info.GetValueFloat((int)SPC.Health); //9 speed = info.GetValueFloat((int)SPC.Speed); //10 resist = info.GetValueFloat((int)SPC.Resist); //11 acidResist = info.GetValueFloat((int)SPC.AcidResist); laserResist = info.GetValueFloat((int)SPC.LaserResist); rocketResist = info.GetValueFloat((int)SPC.RocketResist); hold = info.GetValueInt((int)SPC.Hold); //12 damageBonus = info.GetValueFloat((int)SPC.DamageBonus); //13 color = info.GetValueByte((int)SPC.Color, (byte)ObjectColor.white).toEnum <ObjectColor>(); //16 templateId = info.GetValueString((int)SPC.Template); //17 prefab = info.GetValueString((int)SPC.Prefab); //18 critChance = info.GetValueFloat((int)SPC.CritChance); //19 critDamage = info.GetValueFloat((int)SPC.CritDamage); //20 energyBonus = info.GetValueFloat((int)SPC.EnergyBonus); speedBonus = info.GetValueFloat((int)SPC.SpeedBonus); holdBonus = info.GetValueFloat((int)SPC.HoldBonus); Hashtable craftMaterialsHash = info.GetValueHash((int)SPC.CraftMaterials); this.craftMaterials = craftMaterialsHash.toDict <string, int>(); //23 binded = info.GetValue <bool>((int)SPC.Binded, false); isNew = info.GetValueBool((int)SPC.IsNew); }
public SpecialBotShipComponentData(XElement element) : base(element) { var modulesElement = element.Element("modules"); moduleList = new ConcurrentDictionary <ShipModelSlotType, ModuleGenList>(); var dump = modulesElement.Elements("module").Select(me => { ShipModelSlotType slot = (ShipModelSlotType)Enum.Parse(typeof(ShipModelSlotType), me.GetString("slot")); string id = me.GetString("id"); int level = me.GetInt("level"); string name = me.GetString("name"); Workshop workshop = (Workshop)Enum.Parse(typeof(Workshop), me.GetString("workshop")); string dataId = me.GetString("data_id"); ObjectColor color = (ObjectColor)Enum.Parse(typeof(ObjectColor), me.GetString("color")); string model = me.GetString("model"); float hp = me.GetFloat("hp"); float speed = me.GetFloat("speed"); int hold = me.GetInt("hold"); float critDamage = me.GetFloat("crit_damage"); float resist = me.GetFloat("resist"); float damageBonus = me.GetFloat("damage_bonus"); float energyBonus = me.GetFloat("energy_bonus"); float critChance = me.GetFloat("crit_chance"); float speedBonus = me.GetFloat("speed_bonus"); float holdBonus = me.GetFloat("hold_bonus"); int skill = me.GetInt("skill"); string setId = me.GetString("set_id"); List <DeconstructItem> dItems = me.Element("ditems").Elements("item").Select(die => { return(new DeconstructItem { id = die.GetString("id"), count = die.GetInt("count") }); }).ToList(); ModuleGenList gen = new ModuleGenList { id = id, slot = slot, level = level, name = name, workshop = workshop, dataId = dataId, deconstructOre = dItems, difficulty = difficulty, color = color, model = model, hp = hp, speed = speed, hold = hold, critDamage = critDamage, resist = resist, damageBonus = damageBonus, energyBonus = energyBonus, critChance = critChance, speedBonus = speedBonus, holdBonus = holdBonus, skill = skill, setId = setId }; moduleList.TryAdd(gen.slot, gen); return(gen); }).ToList(); }
public ClientPlayerCharacter(Dictionary <string, object> jsonDictionary) { if (jsonDictionary.ContainsKey("CharacterId")) { object objCharacterId = jsonDictionary["CharacterId"]; if (objCharacterId != null) { CharacterId = objCharacterId.ToString(); } else { CharacterId = string.Empty; } } else { CharacterId = string.Empty; } if (jsonDictionary.ContainsKey("Name")) { object objName = jsonDictionary["Name"]; if (objName != null) { CharacterName = objName.ToString(); } else { CharacterName = string.Empty; } } else { CharacterName = string.Empty; } if (jsonDictionary.ContainsKey("Race")) { object objRace = jsonDictionary["Race"]; if (objRace != null) { Race = int.Parse(objRace.ToString()); } else { Race = (int)Common.Race.Humans; } } else { Race = (int)Common.Race.Humans; } if (jsonDictionary.ContainsKey("Workshop")) { object objWorkshop = jsonDictionary["Workshop"]; if (objWorkshop != null) { HomeWorkshop = int.Parse(objWorkshop.ToString()); } else { HomeWorkshop = (int)(byte)CommonUtils.RandomWorkshop((Race)(byte)Race); } } else { HomeWorkshop = (int)(byte)CommonUtils.RandomWorkshop((Race)(byte)Race); } if (jsonDictionary.ContainsKey("Deleted")) { object objDeleted = jsonDictionary["Deleted"]; if (objDeleted != null) { Deleted = bool.Parse(objDeleted.ToString()); } else { Deleted = false; } } else { Deleted = false; } Model = new Dictionary <ShipModelSlotType, string>(); if (jsonDictionary.ContainsKey("Model")) { List <object> modelObjList = jsonDictionary["Model"] as List <object>; if (modelObjList != null) { foreach (object objModule in modelObjList) { if (objModule != null) { List <object> singleModuleObjList = objModule as List <object>; if (singleModuleObjList != null) { if (singleModuleObjList.Count == 2) { ShipModelSlotType slotType = (ShipModelSlotType)(byte)int.Parse(singleModuleObjList[0].ToString()); string moduleId = singleModuleObjList[1].ToString(); Model.Add(slotType, moduleId); } } } } } } if (jsonDictionary.ContainsKey("WorldId")) { object objWorldId = jsonDictionary["WorldId"]; if (objWorldId != null) { World = objWorldId.ToString(); } else { World = string.Empty; } } else { World = string.Empty; } if (jsonDictionary.ContainsKey("Exp")) { object objExp = jsonDictionary["Exp"]; if (objExp != null) { Exp = int.Parse(objExp.ToString()); } else { Exp = 0; } } else { Exp = 0; } if (jsonDictionary.ContainsKey("guildID")) { object objGuild = jsonDictionary["guildID"]; if (objGuild != null) { guildID = objGuild.ToString(); } else { guildID = string.Empty; } } else { guildID = string.Empty; } if (jsonDictionary.ContainsKey("raceStatus")) { object objRaceStatus = jsonDictionary["raceStatus"]; if (objRaceStatus != null) { raceStatus = int.Parse(objRaceStatus.ToString()); } else { raceStatus = 0; } } else { raceStatus = 0; } if (jsonDictionary.ContainsKey("characterIcon")) { object objIcon = jsonDictionary["characterIcon"]; if (objIcon != null) { icon = int.Parse(objIcon.ToString()); } else { icon = 0; } } else { icon = 0; } }