public void Load() { Start(); log.InfoFormat("ShipWeapon Load() [dy]"); var character = GetComponent <CharacterObject>(); var dropManager = DropManager.Get(nebulaObject.world.Resource()); var player = GetComponent <MmoActor>(); var app = nebulaObject.mmoWorld().application; bool isNew = false; var dbWeapon = WeaponDatabase.instance(app).LoadWeapon(player.GetComponent <PlayerCharacterObject>().characterId, resource as Res, out isNew); if (isNew) { GenerateNewWeapon(dropManager); string characterID = GetComponent <PlayerCharacterObject>().characterId; WeaponDatabase.instance(app).SaveWeapon(characterID, new ShipWeaponSave { characterID = characterID, weaponObject = weaponObject.GetInfo() }); } else { weaponObject = new WeaponObject(dbWeapon.weaponObject); } }
private void Startup() { if (!mInitialized) { mInitialized = true; mEnergy = RequireComponent <ShipEnergyBlock>(); mRace = RequireComponent <RaceableObject>(); mShip = GetComponent <BaseShip>(); var character = GetComponent <CharacterObject>(); var dropManager = DropManager.Get(nebulaObject.world.Resource()); var player = GetComponent <MmoActor>(); if (player != null) { } else { InitializeAsBot(); } mPlayer = GetComponent <MmoActor>(); //log.Info("ShipWeapon.Start() completed"); } }
protected virtual void GenerateWeaponObject(Difficulty difficulty) { var dropParameters = new WeaponDropper.WeaponDropParams( resource, cachedCharacter.level, (Workshop)cachedCharacter.workshop, WeaponDamageType.damage, difficulty ); var dropper = DropManager.Get(resource).GetWeaponDropper(dropParameters); SetWeapon(dropper.Drop() as WeaponObject); }
public void GenerateModel() { if (!modelExist) { modelExist = true; Initialize(); var dropManager = DropManager.Get(resource); GenerateModule(dropManager, ShipModelSlotType.CB); GenerateModule(dropManager, ShipModelSlotType.CM); GenerateModule(dropManager, ShipModelSlotType.DF); GenerateModule(dropManager, ShipModelSlotType.DM); GenerateModule(dropManager, ShipModelSlotType.ES); props.SetProperty((byte)PS.ModelInfo, shipModel.ModelHash()); } }
public void Load() { if (!m_Loaded) { m_Loaded = true; Start(); log.InfoFormat("PlayerShip LOad() [dy]"); var workshop = (Workshop)GetComponent <CharacterObject>().workshop; var dropMgr = DropManager.Get(nebulaObject.world.Resource()); //ShipModelDocument document = GameApplication.Instance.Load(player.nebulaObject.Id, mCharacter.characterId, DatabaseDocumentType.ShipModel) as ShipModelDocument; var app = nebulaObject.mmoWorld().application; bool isNew = false; if (mCharacter == null) { mCharacter = GetComponent <PlayerCharacterObject>(); } if (string.IsNullOrEmpty(mCharacter.characterId)) { mCharacter.SetCharacterId((string)nebulaObject.Tag((byte)PlayerTags.CharacterId)); } var dbModel = ShipModelDatabase.instance(app).LoadShipModel(mCharacter.characterId, resource as Res, out isNew); if (shipModel == null) { SetModel(new ShipModel(resource)); } if (isNew) { GenerateNewShipModel(dropMgr); ShipModelDatabase.instance(app).SaveShipModel(mCharacter.characterId, shipModel); } else { shipModel.Replace(dbModel); } shipModel.Update(); GetComponent <MmoActor>().EventOnShipModelUpdated(); log.Info("PlayerShip.Load() completed"); } }
private ServerInventoryItem GiveWeaponReward(MmoActor player, ContractWeaponDataReward weaponReward) { var playerCharacter = player.GetComponent <CharacterObject>(); WeaponDropper.WeaponDropParams dropParams = new WeaponDropper.WeaponDropParams( player.resource, playerCharacter.level, (Workshop)playerCharacter.workshop, WeaponDamageType.damage, Difficulty.none ); ColorInfo colorInfo = player.resource.ColorRes.Color(ColoredObjectType.Weapon, weaponReward.color); DropManager dropManager = DropManager.Get(player.resource); WeaponDropper weaponDropper = dropManager.GetWeaponDropper(dropParams); WeaponObject weapon = weaponDropper.DropWeapon(colorInfo); return(new ServerInventoryItem(weapon, 1)); }
public override ServerInventoryItem Roll(IRes resource, int level, Workshop workshop) { DropManager dropManager = DropManager.Get(resource); var cl = resource.colorLists.GetList(colorList); ObjectColor color = cl.Roll(); WeaponDropper.WeaponDropParams dropParams = new WeaponDropper.WeaponDropParams( resource, level, workshop, WeaponDamageType.damage, Difficulty.none ); ColorInfo colorInfo = resource.ColorRes.Color(ColoredObjectType.Weapon, color); WeaponDropper weaponDropper = dropManager.GetWeaponDropper(dropParams); WeaponObject weapon = weaponDropper.DropWeapon(colorInfo); return(new ServerInventoryItem(weapon, 1)); }
public override ServerInventoryItem Roll(IRes resource, int level, Workshop workshop) { DropManager dropManager = DropManager.Get(resource); var cl = resource.colorLists.GetList(colorList); ObjectColor color = cl.Roll(); string moduleTemplate = string.Empty; string setId = string.Empty; if (color != ObjectColor.green) { moduleTemplate = resource.ModuleTemplates.RandomModule(workshop, moduleType).Id; } else { var generatedSetInfo = dropManager.GenerateSet(level, workshop, moduleType); if (!string.IsNullOrEmpty(generatedSetInfo.setId)) { moduleTemplate = generatedSetInfo.moduleTemplateId; setId = generatedSetInfo.setId; } else { color = ObjectColor.orange; moduleTemplate = resource.ModuleTemplates.RandomModule(workshop, moduleType).Id; } } ModuleDropper.ModuleDropParams dropParams = new ModuleDropper.ModuleDropParams( resource, moduleTemplate, level, Difficulty.none, new Dictionary <string, int>(), color, setId); ModuleDropper moduleDropper = dropManager.GetModuleDropper(dropParams); ShipModule module = moduleDropper.Drop() as ShipModule; return(new ServerInventoryItem(module, 1)); }
public void TestCase() { Dictionary <ShipModelSlotType, int> countDict = new Dictionary <ShipModelSlotType, int>() { { ShipModelSlotType.CB, 0 }, { ShipModelSlotType.CM, 0 }, { ShipModelSlotType.DF, 0 }, { ShipModelSlotType.DM, 0 }, { ShipModelSlotType.ES, 0 } }; Res res = new Res(@"C:\development\Nebula\TestClient\bin\Debug"); res.Load(); DropManager dropManager = DropManager.Get(res); int totalModules = 0; while (!Check(countDict)) { SchemeDropper schemeDropper = new SchemeDropper(Workshop.RedEye, 5, res); var scheme = schemeDropper.Drop() as SchemeObject; var module = scheme.Transform(dropManager) as ShipModule; totalModules++; if (module.Color == ObjectColor.green) { Console.WriteLine("Green module {0} = {1}", module.SlotType, module.Set); countDict[module.SlotType]++; } } Console.WriteLine("============================"); Console.WriteLine("Total modules = {0}", totalModules); foreach (var pair in countDict) { Console.WriteLine("{0}={1}", pair.Key, pair.Value); } Console.WriteLine("==============================="); }
private void FillForDamager(DamageInfo damager, ItemDropList dropList, ChestSourceInfo sourceInfo) { ConcurrentDictionary <string, ServerInventoryItem> newObjects = new ConcurrentDictionary <string, ServerInventoryItem>(); Workshop lootWorkshop = (Workshop)damager.workshop; //in 10% dropped source workshop items if (sourceInfo != null && sourceInfo.hasWorkshop) { if (Rand.Float01() < 0.1f) { lootWorkshop = sourceInfo.sourceWorkshop; } } DropManager dropManager = DropManager.Get(resource); int lootLevel = damager.level; if (sourceInfo != null && sourceInfo.level != 0) { log.InfoFormat("set loot level = {0} yellow", sourceInfo.level); lootLevel = sourceInfo.level; } Difficulty d = Difficulty.starter; if (sourceInfo != null) { d = sourceInfo.difficulty; } int groupCount = 1; NebulaObject playerObject = GetNebulaObject(damager); groupCount = GetGroupCount(playerObject); float remapWeight = GetColorRemapWeight(playerObject, groupCount); if (dropList == null) { //generate single weapon GenerateWeapons(dropManager, lootLevel, lootWorkshop, d, newObjects, remapWeight); GenerateSchemes(dropManager, lootLevel, lootWorkshop, d, newObjects, remapWeight); } else { GenerateFromDropList( (Race)damager.race, dropManager, lootLevel, lootWorkshop, d, newObjects, remapWeight, dropList, damager.level, groupCount); } //generate single scheme //generate creadits //CreditsObject creadits = new CreditsObject(resource.MiscItemDataRes.CreditsObject()); //creadits.SetCount(20); //newObjects.TryAdd(creadits.Id, creadits); if (content.TryAdd(damager.DamagerId, newObjects)) { if (damager.DamagerType == (byte)ItemType.Avatar) { NotifyChestDamager(damager); } } }
private void RewardItemImpl(InventoryItemQuestReward reward) { ServerInventoryItem targetItem = null; switch (reward.ObjectType) { case InventoryObjectType.Material: { MaterialItemQuestReward materialReward = reward as MaterialItemQuestReward; if (materialReward != null) { MaterialObject material = new MaterialObject(materialReward.OreId); targetItem = new ServerInventoryItem(material, materialReward.Count); } } break; case InventoryObjectType.Scheme: { SchemeItemQuestReward schemeReward = reward as SchemeItemQuestReward; if (schemeReward != null) { SchemeObject scheme = new SchemeObject(new SchemeObject.SchemeInitData( id: Guid.NewGuid().ToString(), name: string.Empty, level: PlayerLevel, workshop: PlayerWorkshop, templateModuleId: resource.ModuleTemplates.Module(PlayerWorkshop, schemeReward.Slot).Id, color: schemeReward.Color, craftingMaterials: new Dictionary <string, int>(), inSetID: string.Empty )); targetItem = new ServerInventoryItem(scheme, schemeReward.Count); } } break; case InventoryObjectType.Weapon: { WeaponItemQuestReward weaponReward = reward as WeaponItemQuestReward; if (weaponReward != null) { WeaponDropper.WeaponDropParams weaponDropParams = new WeaponDropper.WeaponDropParams( resource: resource, level: PlayerLevel, workshop: PlayerWorkshop, damageType: WeaponDamageType.damage, difficulty: Difficulty.none ); ColorInfo colorInfo = resource.ColorRes.Color(ColoredObjectType.Weapon, weaponReward.Color); DropManager dropManager = DropManager.Get(resource); WeaponDropper weaponDropper = dropManager.GetWeaponDropper(dropParams: weaponDropParams); WeaponObject weapon = weaponDropper.DropWeapon(colorInfo); targetItem = new ServerInventoryItem(weapon, weaponReward.Count); } } break; } if (targetItem != null) { GetComponent <MmoActor>()?.AddToStationInventory(item: targetItem, sendUpdateEvent: true); } }