public void AddLootedEquipment(ShipEquipment equipment) { if (equipment != null) { allLootedEquipments.Add(equipment); } }
public void CloseInformationsPanel() { currentEquipmentSlot = null; currentEquipment = null; informationsInterface.CloseInformationsPanel(); }
public void RemoveEquipment(ShipEquipment equipmentToRemove) { if (selectedBuyableEquipments != null) { selectedBuyableEquipments.Remove(equipmentToRemove); } }
public void RemoveSoldEquipment(ShipEquipment equipmentToRemove) { if (soldEquipments != null) { soldEquipments.Remove(equipmentToRemove); } }
public void AddSoldEquipment(ShipEquipment equipmentToAdd) { if (soldEquipments == null) { soldEquipments = new List <ShipEquipment>(); } soldEquipments.Add(equipmentToAdd); }
// Add Equipments void AddPowerEquipment(Ship ship, ShipEquipment equipment) { //GameObject shipObject = ship.gameObject; //CmpPower cmp = shipObject.GetComponent<CmpPower>(); //if (!cmp) { // cmp = shipObject.AddComponent<CmpPower>() as CmpPower; // ship.CmpMining = cmp; //} //cmp.Add((PowerEquipment)attachment); }
public void SetPlacedEquipment(ShipEquipment newEquipment) { placedEquipment = newEquipment; if (placedEquipment != null) { objectImage.sprite = placedEquipment.GetEquipmentInformations.GetEquipmentIcon; } else { objectImage.sprite = null; } }
public void RemoveSoldEquipmentToSellerShop(ShipEquipment shipEquipment) { currentSellerShopParameters.RemoveSoldEquipment(shipEquipment); foreach (ShopWithShopParameters parameters in allShopsWithParameters) { if (parameters.GetShopParameters == currentSellerShopParameters) { SaveShopParameters(parameters); } } //SaveSellerDatas(); }
/// <summary> /// Removes one instance of the select hull /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_RemoveEquip_Click(object sender, RoutedEventArgs e) { if (Tabs_Embarked.SelectedIndex != 1) { return; } ShipEquipment equip = List_EmbarkedEquip.SelectedItem as ShipEquipment; if (equip != null) { RemoveEquipment(currentVessel.id, equip.hull.id); } }
public int GetIndex(ShipEquipment equipToFind) { foreach (ShipEquipment equip in allGameEquipments) { if (equip != null) { if (equip == equipToFind) { return(equip.GetEquipmentSaveIndex); } } } Debug.LogWarning("Equipement introuvable"); return(-1); }
public List <ShipEquipment> IndexesToEquipments(List <int> indexes) { List <ShipEquipment> allEquipments = new List <ShipEquipment>(); foreach (int index in indexes) { ShipEquipment equip = allGameEquipments.GetEquipment(index); if (equip != null) { allEquipments.Add(equip); } } return(allEquipments); }
public void OpenInformationsPanel(EquipmentSlot slot, bool noInteractions) { currentEquipmentSlot = slot; currentEquipment = currentEquipmentSlot.GetPlacedEquipment; informationsInterface.OpenInformationPanel(currentEquipment.GetEquipmentInformations, currentEquipment.GetEquipmentType); if (noInteractions) { informationsInterface.CloseAllActions(); } else { switch (slot.GetEquipmentActionsType) { case (EquipmentInformationsOpeningType.EquipOrUpgrade): informationsInterface.OpenPlayerInventoryEquipmentActions(currentEquipment.Upgradable, currentEquipment.PriceToUpgrade, currentEquipment.GetSellingPrice); break; case (EquipmentInformationsOpeningType.Upgrade): informationsInterface.OpenPlayerEquippedEquipmentActions(currentEquipment.Upgradable, currentEquipment.PriceToUpgrade); break; case (EquipmentInformationsOpeningType.Buy): informationsInterface.OpenSellerEquipmentActions(currentEquipment.PriceToBuy); break; case (EquipmentInformationsOpeningType.Throw): informationsInterface.OpenThrowEquipmentActions(); break; } } if (currentEquipment.GetEquipmentType == EquipmentType.Hull) { ShipEquipmentHull hull = currentEquipment as ShipEquipmentHull; if (hull != null) { informationsInterface.OpenHullInformations(hull.GetShipMaximumLife, hull.GetShipMaximumArmor); } } else { EquipmentInformations infos = currentEquipment.GetEquipmentInformations; informationsInterface.OpenWeaponInformations(infos.GetWeaponType, infos.GetWeaponShotType, infos.GetWeaponEffect); } }
public void AddSoldEquipmentToSellerShop(ShipEquipment shipEquipment) { currentSellerShopParameters.AddSoldEquipment(shipEquipment); if (currentSellerShopParameters.GetSoldEquipments.Count > mapDocksInterface.GetSoldEquipmentsCapacity) { currentSellerShopParameters.RemoveOldestSoldEquipment(); } foreach (ShopWithShopParameters parameters in allShopsWithParameters) { if (parameters.GetShopParameters == currentSellerShopParameters) { SaveShopParameters(parameters); } } //SaveSellerDatas(); }
public void TryEquipEquipment(EquipmentSlot equipmentSlot) { ShipEquipment equipment = equipmentSlot.GetPlacedEquipment; mapManager.ShipCompoManager.EquipSelectedObject(equipmentSlot as EquipmentSlotInventory); mapManager.EquipmentsInfoManager.CloseInformationsPanel(); inventoryManager.UpdatePlayerEquipmentValue(); mapManager.SavePlayerDatas(); ShipEquipmentHull hull = equipment as ShipEquipmentHull; if (hull != null) { //docksInterface.UpdatePlayerHullLifeText(hull.GetShipMaximumLife); docksInterface.UpdatePlayerHullArmorText(Mathf.Clamp(IntersceneManager.intersceneManager.GetPlayerDatas.GetPlayerCurrentArmorValue, 0, hull.GetShipMaximumArmor), hull.GetShipMaximumArmor); } }
public void TryBuyEquipment(EquipmentSlot equipmentSlot) { ShipEquipment equipmentToBuy = equipmentSlot.GetPlacedEquipment; if (inventoryManager.GetPlayerInventoryEquipments.Count < IntersceneManager.intersceneManager.GetPlayerDatas.GetPlayerInventoryCapacity) { if (IntersceneManager.intersceneManager.GetPlayerDatas.GetPlayerGoldAmount >= equipmentToBuy.PriceToBuy) { IntersceneManager.intersceneManager.GetPlayerDatas.SpendMoney(equipmentToBuy.PriceToBuy); if (docksInterface.SellerInventoryOpened) { sellerManager.RemoveEquipmentFromSellerShop(equipmentToBuy); docksInterface.OpenSellerInventoryPanel(sellerManager.GetBuyableEquipments); } else if (docksInterface.SellerRebuyInventoryOpened) { sellerManager.RemoveSoldEquipmentToSellerShop(equipmentToBuy); docksInterface.OpenSellerRebuyInventoryPanel(sellerManager.GetSoldEquipments); } inventoryManager.AddNewEquipmentToInventory(equipmentToBuy); docksInterface.OpenPlayerInventoryPanel(inventoryManager.GetPlayerInventoryEquipments); mapManager.EquipmentsInfoManager.CloseInformationsPanel(); inventoryManager.UpdatePlayerEquipmentValue(); //docksInterface.OpenPlayerInventoryPanel(inventoryManager.GetPlayerInventoryEquipments); mapManager.SavePlayerDatas(); docksInterface.UpdatePlayerGoldText(); } else { Debug.Log("Not enough money, kid"); } } else { Debug.Log("trop d'objets dans l'inventaire pour acheter"); } }
public void SetUpSelectedObjects() { selectedBuyableEquipments = new List <ShipEquipment>(); List <ShipEquipment> equips = new List <ShipEquipment>(allBuyableEquipments); int numberOfEquipments = Random.Range(minNumberOfEquipments, maxNumberOfEquipments); for (int i = 0; i < numberOfEquipments; i++) { if (equips.Count == 0) { break; } ShipEquipment equip = equips.GetRandomMemberOfTheList(); selectedBuyableEquipments.Add(equip); equips.Remove(equip); } }
void Awake() { //mBody = GetComponent<Rigidbody>(); visibilityRadius = NetworkManager.visibilityRadius; //Instantiate(inventory); inventory = GetComponent <Inventory>(); ship_equipment = GetComponent <ShipEquipment>(); //player_equipment = GetComponent<PlayerEquipment>(); movement = GetComponent <BoatMovement>(); playerEnterCollider = GetComponentInChildren <SphereCollider>(); playerEnterCollider.radius = NetworkManager.visibilityRadius / 2; //enable collider for ship when we have player character playerEnterCollider.enabled = false; mysql = FindObjectOfType <Mysql>(); cannonShot = GetComponent <CannonShot>(); cannonController = GetComponent <CannonController>(); spawnManager = FindObjectOfType <SpawnManager>(); }
public void SetBoxLoot(int gold, ShipEquipment equipment) { lootingPlayer = null; baseLootingPosition = Vector3.zero; remainingLootingDuration = 0; lootedGold = gold; lootedEquipment = equipment; gameObject.SetActive(true); DebugLootContent(); lootingCollider.radius = lootingRadius; //shinyParticles.Play(); transform.rotation = Quaternion.identity; }
public void TryUpgradeEquipment(EquipmentSlot equipmentSlot) { ShipEquipment equipmentToUpgrade = equipmentSlot.GetPlacedEquipment; if (IntersceneManager.intersceneManager.GetPlayerDatas.GetPlayerGoldAmount >= equipmentToUpgrade.PriceToUpgrade) { IntersceneManager.intersceneManager.GetPlayerDatas.SpendMoney(equipmentToUpgrade.PriceToUpgrade); equipmentSlot.SetPlacedEquipment(equipmentToUpgrade.GetUpgradedEquipment); mapManager.EquipmentsInfoManager.OpenInformationsPanel(equipmentSlot, false); inventoryManager.UpdatePlayerEquipmentValue(); mapManager.SavePlayerDatas(); docksInterface.UpdatePlayerGoldText(); } else { } }
public SellerShopParameters(SellerShopParameters parameters) { allBuyableEquipments = parameters.allBuyableEquipments; selectedBuyableEquipments = new List <ShipEquipment>(); List <ShipEquipment> equips = new List <ShipEquipment>(allBuyableEquipments); int numberOfEquipments = Random.Range(minNumberOfEquipments, maxNumberOfEquipments); for (int i = 0; i < numberOfEquipments; i++) { if (equips.Count == 0) { break; } ShipEquipment equip = equips.GetRandomMemberOfTheList(); selectedBuyableEquipments.Add(equip); equips.Remove(equip); } soldEquipments = new List <ShipEquipment>(); }
public virtual void SetPlacedEquipment(EquipmentSlot originSlot, bool replace) { ShipEquipment newEquip = originSlot.placedEquipment; if (replace) { originSlot.SetPlacedEquipment(this, false); } placedEquipment = newEquip; if (placedEquipment != null) { objectImage.sprite = placedEquipment.GetEquipmentInformations.GetEquipmentIcon; } else { objectImage.sprite = null; } placementTimer = 0.01f; }
public void SetUpCrate(ShipEquipment equipment, Transform cameraTransform, float waitTimeBeforeAppear) { basePos = transform.localPosition; Vector3 lookDirection = cameraTransform.position - transform.position; if (Mathf.Abs(lookDirection.z) > 1) { float rotY = Mathf.Atan2(lookDirection.x, lookDirection.z) * Mathf.Rad2Deg; transform.localRotation = Quaternion.Euler(new Vector3(0, 180 + rotY, 0)); } containedEquipment = equipment; gameObject.SetActive(true); crateRenderer.gameObject.SetActive(true); if (lootedEquipmentImage != null) { lootedEquipmentImage.gameObject.SetActive(false); if (containedEquipment.GetEquipmentInformations.GetEquipmentIcon != null) { lootedEquipmentImage.sprite = containedEquipment.GetEquipmentInformations.GetEquipmentIcon; } } openable = true; //Interaction = OpenCrate; if (waitTimeBeforeAppear != 0) { remainingTimeBeforeAppear = waitTimeBeforeAppear; } else { Appear(); } lootedEquipmentText.text = containedEquipment.GetEquipmentInformations.GetEquipmentName; lootedEquipmentText.enabled = false; }
public void RemoveEquipmentFromSellerShop(ShipEquipment shipEquipment) { currentSellerShopParameters.RemoveEquipment(shipEquipment); }
public void RemoveEquipmentFromInventory(ShipEquipment equipmentToRemove) { playerEquipments.Remove(equipmentToRemove); mapDocksInterface.OpenPlayerInventoryPanel(playerEquipments); }
public void AddNewEquipmentToInventory(ShipEquipment newEquipment) { playerEquipments.Add(newEquipment); }
public void Load() { Mysql mysql = FindObjectOfType <Mysql>(); Action ac = () => { try { List <ShipBaseStat> stats = mysql.ReadShipBaseStatsTable(); List <Experience> exp = mysql.ReadExperienceTable(); PlayerData data = mysql.ReadPlayerData(dbid); List <PlayerSkillLevel> skills = mysql.ReadPlayerSkills(dbid); this.stats = stats; this.exp = exp; this.data = data; this.skills = skills; if (!NetworkManager.traders.ContainsKey(dbid)) { NetworkManager.traders.Add(dbid, mysql.ReadTraders()); } List <SerializableObjects.Item> shipEquipment = LoadShipEquipment(mysql); List <SerializableObjects.Equipment> playerEquipment = LoadPlayerEquipment(mysql); List <SerializableObjects.InventorySlot> inventory = LoadInventory(mysql); List <RandomLoot> loot = mysql.LoadPlayerLoot(dbid); if (!GameServer.playerLoot.ContainsKey(id)) { GameServer.playerLoot.Add(id, null); } GameServer.playerLoot[id] = loot; foreach (RandomLoot l in loot) { ServerSend.OnLootDropped(id, l.id, l.position); } mysql.RemovePlayerLoot(dbid); List <Buff> buffs = mysql.GetPlayerBuffs(dbid); mysql.RemoveBuffs(dbid); List <PlayerBaseStat> playerStats = mysql.ReadPlayerBaseStatsTable(); ThreadManager.ExecuteOnMainThread(() => { LoadBaseStats(); //if (!data.is_on_ship) { playerInstance = Instantiate(playerPrefab, new Vector3(data.X_PLAYER, data.Y_PLAYER, data.Z_PLAYER), Quaternion.identity); playerCharacter = playerInstance.GetComponent <PlayerCharacter>(); playerMovement = playerInstance.GetComponent <PlayerMovement>(); playerCharacter.id = id; playerCharacter.data = data; playerInstance.transform.Find("PlayerSphere").GetComponent <SphereCollider>().radius = NetworkManager.visibilityRadius / 2; playerInstance.transform.eulerAngles = new Vector3(0, data.Y_ROT_PLAYER, 0); playerCharacter.pirate.transform.rotation = Quaternion.Euler(0, data.Y_ROT_PLAYER_CHILD, 0); //enable collider for ship when we have player character playerEnterCollider.enabled = true; playerCharacter.clientPosition = new Vector3(data.X_PLAYER, data.Y_PLAYER, data.Z_PLAYER); playerCharacter.clientRotation = Quaternion.Euler(0, data.Y_ROT_PLAYER, 0); playerCharacter.childRotation = Quaternion.Euler(0, data.Y_ROT_PLAYER_CHILD, 0); if (data.is_on_ship) { playerInstance.SetActive(false); } Inventory inv = this.inventory; foreach (SerializableObjects.InventorySlot slot in inventory) { inv.Add(NetworkManager.SerializableToSlot(slot)); } playerCharacter.stats = playerStats; playerCharacter.Load(); ServerSend.SpawnShip(id, this); ServerSend.OnGameStart(id, stats, playerCharacter.stats, exp, data); ShipEquipment equipment = ship_equipment; foreach (SerializableObjects.Item item in shipEquipment) { equipment.Add(NetworkManager.SerializableToItem(item), null); } foreach (SerializableObjects.Equipment eq in playerEquipment) { playerCharacter.equipment.Add(NetworkManager.SerializableToItem(eq.item), eq.slotType); } // Send the new player to all players foreach (Client _client in GameServer.clients.Values) { if (_client.player != null) { if (_client.player.id != id) { ServerSend.SpawnShip(_client.id, this); } } } // Send all players to the new player foreach (Client _client in GameServer.clients.Values) { if (_client.player != null) { if (_client.id != id) { ServerSend.SpawnShip(id, _client.player); } } } // Send the new player to all players except himself foreach (Client _client in GameServer.clients.Values) { if (_client.player != null) { if (_client.player.id != id) { //ServerSend.SpawnPlayer(_client.id, player); ServerSend.InstantiatePlayerCharacter(_client.id, id, this.playerInstance.transform.position, this.playerInstance.transform.eulerAngles.y); } } } // Send all players to the new player foreach (Client _client in GameServer.clients.Values) { if (_client.player != null) { if (_client.id != id) { /*if(!_client.player.data.is_on_ship) * ServerSend.SpawnPlayer(id, _client.player);*/ ServerSend.InstantiatePlayerCharacter(id, _client.player.id, _client.player.playerInstance.transform.position, _client.player.playerInstance.transform.eulerAngles.y); } } } spawnManager.SendAllGameObjects(id); ServerSend.Recipes(id); //send stats after all is loaded ServerSend.Stats(id); if (data.dead) { playerCharacter.Respawn(); } foreach (RandomLoot l in loot) { StartCoroutine(GameServer.DespawnLoot(id, l, l.remainingTime)); } foreach (Buff b in buffs) { playerCharacter.buffManager.AddBuff(b); } ServerSend.Buffs(id, id); }); //LoadPlayerEquipment(); } catch (Exception ex) { Debug.LogError(ex); } }; Task task = new Task(ac); task.Start(); }
void AddSpecialEquipment(Ship ship, ShipEquipment equipment) { }
void AddStorageEquipment(Ship ship, ShipEquipment equipment) { }
void AddEngineEquipment(Ship ship, ShipEquipment equipment) { }
public List <ShipEquipment> ChangePlayerLootWithRarity(List <ShipEquipment> baseLoot, int numberOfStars) { #region Lists Composition List <ShipEquipment> nonUpgradedEquipments = new List <ShipEquipment>(baseLoot); List <ShipEquipment> modifiedEquipments = new List <ShipEquipment>(); List <ShipEquipment> upgradableToLevel2Equipments = new List <ShipEquipment>(); List <ShipEquipment> upgradableToLevel3Equipments = new List <ShipEquipment>(); foreach (ShipEquipment equip in nonUpgradedEquipments) { if (equip.Upgradable) { ShipEquipment level2Equip = equip.GetUpgradedEquipment; upgradableToLevel2Equipments.Add(equip); if (level2Equip.Upgradable) { //ShipEquipment level3Equip = level2Equip.GetUpgradedEquipment; upgradableToLevel3Equipments.Add(equip); } } } #endregion #region Pick Number of Upgraded Equipments int numberOfLevel2Equipments = 0; int numberOfLevel3Equipments = 0; if (numberOfStars == 1) { numberOfLevel2Equipments = oneStarLevel2EquipmentsProbabilities.GetRandomElementFromSystem(); numberOfLevel3Equipments = oneStarLevel3EquipmentsProbabilities.GetRandomElementFromSystem(); } else if (numberOfStars == 2) { numberOfLevel2Equipments = twoStarsLevel2EquipmentsProbabilities.GetRandomElementFromSystem(); numberOfLevel3Equipments = twoStarsLevel3EquipmentsProbabilities.GetRandomElementFromSystem(); } else if (numberOfStars == 3) { numberOfLevel2Equipments = threeStarsLevel2EquipmentsProbabilities.GetRandomElementFromSystem(); numberOfLevel3Equipments = threeStarsLevel3EquipmentsProbabilities.GetRandomElementFromSystem(); } #endregion /*Debug.Log(numberOfLevel2Equipments + " Niv2"); * Debug.Log(numberOfLevel3Equipments + " Niv3");*/ #region Create new dropped equipments for (int i = 0; i < numberOfLevel3Equipments; i++) { if (upgradableToLevel3Equipments.Count == 0) { numberOfLevel2Equipments += (numberOfLevel3Equipments - i); break; } ShipEquipment pickedEquipment = upgradableToLevel3Equipments.GetRandomMemberOfTheList(); upgradableToLevel3Equipments.Remove(pickedEquipment); upgradableToLevel2Equipments.Remove(pickedEquipment); nonUpgradedEquipments.Remove(pickedEquipment); modifiedEquipments.Add(pickedEquipment.GetUpgradedEquipment.GetUpgradedEquipment); } for (int i = 0; i < numberOfLevel2Equipments; i++) { if (upgradableToLevel2Equipments.Count == 0) { break; } ShipEquipment pickedEquipment = upgradableToLevel2Equipments.GetRandomMemberOfTheList(); upgradableToLevel2Equipments.Remove(pickedEquipment); nonUpgradedEquipments.Remove(pickedEquipment); modifiedEquipments.Add(pickedEquipment.GetUpgradedEquipment); } #endregion foreach (ShipEquipment equip in nonUpgradedEquipments) { modifiedEquipments.Add(equip); } return(modifiedEquipments); }