///Returns next decision branch to take (from branches array), -1 if this ends the chain ///Different results can be decided here with basic float value = Random.value and > switches public override int onChosen() { SupplyData sD = GameObject.FindObjectOfType <SupplyData>(); if (sD.gold < 5) { int select = Random.Range(0, 99); if (select > 75) { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[0]; sD.gold = Mathf.Clamp(sD.gold, 0, sD.gold - 5); sD.food = Mathf.Clamp(sD.food, 0, sD.food + 15); } else if (select > 10) { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[1]; sD.gold = Mathf.Clamp(sD.gold, 0, sD.gold - 5); sD.food = Mathf.Clamp(sD.food, 0, sD.food + 8); } else { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[2]; sD.gold = Mathf.Clamp(sD.gold, 0, sD.gold - 5); } } else { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[3]; } return(-1); }
public void RpcTurnStart() { if (hasAuthority) { foreach (FollowerMovement f in GameObject.FindObjectsOfType <FollowerMovement>()) { f.rooted = false; } SupplyData sD = GameObject.FindObjectOfType <SupplyData>(); sD.gold += sD.workers; sD.food = Mathf.Clamp(sD.food, 0, sD.food - (int)Mathf.Ceil((sD.fighters + sD.workers) / 4)); if (sD.food < 0) { sD.fighters = Mathf.Clamp(sD.fighters, 0, sD.fighters - 1); } } foreach (Building b in GameObject.FindObjectsOfType <Building>()) { b.OnTurnStart(); } int roll = Random.Range(0, 99); if (hasAuthority && Random.Range(0, 99) >= 0) { FightManager.i.StartFight(5); } else if (hasAuthority && Random.Range(0, 99) >= 1000) { QuestHandler qH = GameObject.FindObjectOfType <QuestHandler>(); qH.SelectQuest(); } }
///Returns next decision branch to take (from branches array), -1 if this ends the chain ///Different results can be decided here with basic float value = Random.value and > switches public override int onChosen() { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[0]; SupplyData sD = GameObject.FindObjectOfType <SupplyData>(); sD.gold = Mathf.Clamp(sD.gold, 0, sD.gold - 5); sD.food = Mathf.Clamp(sD.food, 0, sD.food - 5); return(-1); }
public DateTimeOffset OrderItem(string code, int quantity, DateTimeOffset requiredDate) { var data = new SupplyData(); if (!data.TryDepleteStock(code, quantity)) { throw new Exception("Item unavailable"); } return(requiredDate); }
public IEnumerable <SupplyItem> GetSupplies() { var data = new SupplyData(); return(data.GetItems().Select(i => new SupplyItem { Code = i.Code, Description = i.Description, Available = i.Available, Price = i.Price })); }
// Update is called once per frame void Update() { if (data == null) { data = GameObject.FindObjectOfType <SupplyData>(); return; } children[0].text = data.food.ToString(); children[1].text = data.wood.ToString(); children[2].text = data.stone.ToString(); children[3].text = data.gold.ToString(); children[4].text = data.workers.ToString(); children[5].text = data.fighters.ToString(); }
protected void createSupplyDrop() { SupplyData data = Data.Instance.getSupplyById(id); if (data != null) { Vector3 position = transform.position; position.y += 1f; Quaternion rotation = Quaternion.Euler(-90f, 0f, 90f); dropItem = Instantiate(data.prefab, position, rotation) as GameObject; dropItem.transform.SetParent(transform); } else { Destroy(gameObject); } }
public static SupplyData createSupplyData(SupplyType type, ItemQuality quality) { float level = randLevel(); int value = 0; int duration = 0; switch (type) { case SupplyType.MEDKIT_SMALL: case SupplyType.MEDKIT_MEDIUM: case SupplyType.MEDKIT_LARGE: case SupplyType.MEDKIT_ULTRA: value = Mathf.RoundToInt(type.value() * level * qualityMultiplier(quality)); break; case SupplyType.GRENADE_FLASH: duration = quality == ItemQuality.UNIQUE? 12: quality == ItemQuality.RARE? 10: quality == ItemQuality.SUPERIOR? 8: quality == ItemQuality.GOOD? 6: 4; break; case SupplyType.GRENADE_PARALIZE: duration = quality == ItemQuality.UNIQUE? 7: quality == ItemQuality.RARE? 6: quality == ItemQuality.SUPERIOR? 5: quality == ItemQuality.GOOD? 4: 3; break; case SupplyType.INJECTION_ARMOR: value = Mathf.RoundToInt(type.value() * level * qualityMultiplier(quality)) * 2; duration = quality == ItemQuality.UNIQUE? 20: quality == ItemQuality.RARE? 14: quality == ItemQuality.SUPERIOR? 10: quality == ItemQuality.GOOD? 7: 5; break; case SupplyType.INJECTION_REGENERATION: value = Mathf.RoundToInt(type.value() * level * qualityMultiplier(quality)); duration = quality == ItemQuality.UNIQUE? 7: quality == ItemQuality.RARE? 6: quality == ItemQuality.SUPERIOR? 5: quality == ItemQuality.GOOD? 4: 3; break; case SupplyType.INJECTION_SPEED: value = quality == ItemQuality.UNIQUE? 5: quality == ItemQuality.RARE? 4: quality == ItemQuality.SUPERIOR? 3: quality == ItemQuality.GOOD? 2: 1; duration = 5; break; } SupplyData data = new SupplyData(quality, level, type, value, duration); data.initCommons(calculateCost(data), 0); return(data); }
///Returns next decision branch to take (from branches array), -1 if this ends the chain ///Different results can be decided here with basic float value = Random.value and > switches public override int onChosen() { SupplyData sD = GameObject.FindObjectOfType <SupplyData>(); if (sD.fighters > 5) { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[0]; sD.fighters = Mathf.Clamp(sD.fighters, 0, sD.fighters - Random.Range(0, 1)); sD.gold = Mathf.Clamp(sD.gold, 0, sD.gold + 5); sD.food = Mathf.Clamp(sD.food, 0, sD.food + 5); } else { GameObject.FindObjectOfType <QuestHandler>().eventDescription.text = EndingDescriptions[1]; sD.fighters = Mathf.Clamp(sD.fighters, 0, sD.fighters - 5); sD.gold = Mathf.Clamp(sD.gold, 0, sD.gold - 5); sD.food = Mathf.Clamp(sD.food, 0, sD.food - 5); } return(-1); }
public void useSupply(int id) { SupplyData data = Data.Instance.getSupplyById(id); if (data != null) { switch (data.kind) { case SupplyType.HEALTH: owner.player.applyhealth(data.value); break; case SupplyType.ARMOR: owner.player.armor += data.value; break; default: break; } } }
// Update is called once per frame void Update() { if (inCombat && UnitManager.i.enemyFighters.Count == 0 && isServer) { inCombat = false; var players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject player in players) { player.transform.position = Vector3.zero; } foreach (AttackerMovement fighter in GameObject.FindObjectsOfType <AttackerMovement>()) { UnitManager.i.DestroyUnit(fighter.gameObject); SupplyData sd = GameObject.FindObjectOfType <SupplyData>(); sd.fighters++; } } else if (inCombat && inCombatPlayers <= 0) { Network.Disconnect(); } }
public void StartFight(int enemies) { inCombatPlayers = 0; inCombat = true; var players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject player in players) { player.transform.position = new Vector3(55, 3, 0); player.GetComponent <AttackSystem>().health = 1000; inCombatPlayers++; } SupplyData s = GameObject.FindObjectOfType <SupplyData>(); for (int i = 0; s.fighters > 0 && i < 5; ++i) { UnitManager.i.SpawnUnit(new Vector3(52, 1.5f * i, 0), UnitAlliance.FriendlyFighter, 0, Resources.Load <GameObject>("NetworkPrefabs/Attacker")); s.fighters--; //The numer displayed is the reserve of soldiers, hence the removal } for (int i = 0; i < enemies; ++i) { UnitManager.i.SpawnUnit(new Vector3(65, 1.5f * i, 0), UnitAlliance.EnemyFighter, 1, Resources.Load <GameObject>("NetworkPrefabs/Attacker")); } }
public static ItemData copy(ItemData source) { ItemData copy = null; switch (source.itemType) { case ItemType.SUPPLY: SupplyData sud = (SupplyData)source; copy = new SupplyData(sud.quality, sud.level, sud.type, sud.value, sud.duration); break; case ItemType.GOODS: GoodsData gda = (GoodsData)source; copy = new GoodsData(gda.type, gda.quantity); break; case ItemType.HAND_WEAPON: HandWeaponData hwd = (HandWeaponData)source; copy = new HandWeaponData(source.quality, source.level, hwd.type, hwd.minDamage, hwd.maxDamage); break; case ItemType.BODY_ARMOR: BodyArmorData bad = (BodyArmorData)source; copy = new BodyArmorData(source.quality, source.level, bad.type, bad.armorClass); break; case ItemType.WEAPON: WeaponData wd = (WeaponData)source; copy = new WeaponData(source.quality, source.level, wd.type, wd.minDamage, wd.maxDamage, wd.reloadTime); break; case ItemType.ENGINE: EngineData ed = (EngineData)source; copy = new EngineData(source.quality, source.level, ed.type, ed.power); break; case ItemType.ARMOR: ArmorData ad = (ArmorData)source; copy = new ArmorData(source.quality, source.level, ad.type, ad.armorClass); break; case ItemType.GENERATOR: GeneratorData gd = (GeneratorData)source; gd = new GeneratorData(source.quality, source.level, gd.type, gd.maxEnergy); break; case ItemType.RADAR: RadarData rd = (RadarData)source; copy = new RadarData(source.quality, source.level, rd.type, rd.range); break; case ItemType.SHIELD: ShieldData sd = (ShieldData)source; copy = new ShieldData(source.quality, source.level, sd.type, sd.shieldLevel, sd.rechargeSpeed); break; case ItemType.REPAIR_DROID: RepairDroidData rdd = (RepairDroidData)source; copy = new RepairDroidData(source.quality, source.level, rdd.type, rdd.repairSpeed); break; case ItemType.HARVESTER: HarvesterData hd = (HarvesterData)source; copy = new HarvesterData(source.quality, source.level, hd.type, hd.harvestTime); break; default: Debug.Log("Unknown item type to copy from: " + source.itemType); break; } copy.initCommons(source.cost, source.energyNeeded); return(copy); }
public SupplyServiceImpl(SupplyData data) { _data = data; }
private void showTexts(ItemData data) { float maxLenght = 0; if (data.quality != ItemQuality.COMMON) { qualityPre.gameObject.SetActive(true); qualityBG.gameObject.SetActive(true); qualityValue.gameObject.SetActive(true); qualityValue.text = item.quality.getName(); scale.x = calcMeshLength(qualityRender);// qualityValue.text.Length + 1; qualityBG.localScale = scale; qualityValue.color = (data.quality == ItemQuality.ARTEFACT? artefactColor: data.quality == ItemQuality.UNIQUE? uniqueColor: data.quality == ItemQuality.RARE? rareColor: data.quality == ItemQuality.SUPERIOR? superiorColor: goodColor); maxLenght = qualityRender.bounds.size.x; } namePre.gameObject.SetActive(true); nameBG.gameObject.SetActive(true); nameValue.gameObject.SetActive(true); nameValue.text = data.name; scale.x = calcMeshLength(nameRender);// nameValue.text.Length + 1; nameBG.localScale = scale; maxLenght = Mathf.Max(maxLenght, nameRender.bounds.size.x); switch (data.itemType) { case ItemType.SUPPLY: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); SupplyData sud = (SupplyData)data; string val = ""; switch (sud.type) { case SupplyType.MEDKIT_SMALL: case SupplyType.MEDKIT_MEDIUM: case SupplyType.MEDKIT_LARGE: case SupplyType.MEDKIT_ULTRA: val = "Восстанавливает <color=white>" + sud.value + "</color> HP"; break; case SupplyType.GRENADE_FLASH: val = StatusEffectType.BLINDED.name() + " на <color=white>" + sud.duration + "</color> ходов"; break; case SupplyType.GRENADE_PARALIZE: val = StatusEffectType.PARALIZED.name() + " на <color=white>" + sud.duration + "</color> ходов"; break; case SupplyType.INJECTION_SPEED: val = "Дополнительно <color=white>" + sud.value + "</color> действий на <color=white>" + sud.duration + "</color> ходов"; break; case SupplyType.INJECTION_REGENERATION: val = "Восстановление по <color=white>" + sud.value + "</color> HP в течении <color=white>" + sud.duration + "</color> ходов"; break; case SupplyType.INJECTION_ARMOR: val = "Повышение защиты на <color=white>" + sud.value + "</color> в течении <color=white>" + sud.duration + "</color> ходов"; break; default: Debug.Log("Unknown supply type: " + sud.type); val = ""; break; } value1.text = "Эффект: <color=orange>" + val + "</color>"; scale.x = calcMeshLength(value1Render); // value1Render.bounds.size.x * 4.8f;// value1.text.Length - 23;// - (количество спецсимволов) bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(2, data)); break; case ItemType.GOODS: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); maxLenght = Mathf.Max(maxLenght, setCost(1, data)); break; case ItemType.HAND_WEAPON: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); HandWeaponData hwd = (HandWeaponData)data; value1.text = "Урон: <color=orange>" + hwd.minDamage + " - " + hwd.maxDamage + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 24;// - (количество спецсимволов) bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(2, data)); break; case ItemType.BODY_ARMOR: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); BodyArmorData bad = (BodyArmorData)data; value1.text = "Защита: <color=orange>" + bad.armorClass + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(2, data)); break; case ItemType.WEAPON: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); pre4.gameObject.SetActive(true); bg4.gameObject.SetActive(true); value4.gameObject.SetActive(true); pre5.gameObject.SetActive(true); bg5.gameObject.SetActive(true); value5.gameObject.SetActive(true); WeaponData wd = (WeaponData)data; value1.text = "Урон: <color=orange>" + wd.minDamage + " - " + wd.maxDamage + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 24; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Перезарядка: <color=orange>" + wd.reloadTime.ToString("0.00") + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 22.5F; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); value3.text = "Питание: <color=cyan>" + data.energyNeeded + "</color>"; scale.x = calcMeshLength(value3Render); //value3.text.Length - 20.5f; bg3.localScale = scale; maxLenght = Mathf.Max(maxLenght, value3Render.bounds.size.x); value4.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value4Render); //value4.text.Length - 22.5F; bg4.localScale = scale; maxLenght = Mathf.Max(maxLenght, value4Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(5, data)); break; case ItemType.ENGINE: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); pre4.gameObject.SetActive(true); bg4.gameObject.SetActive(true); value4.gameObject.SetActive(true); EngineData ed = (EngineData)data; value1.text = "Мощность: <color=orange>" + ((ed.power) * 1000).ToString("0") + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Питание: <color=cyan>" + data.energyNeeded + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 20.5f; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); value3.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value3Render); //value3.text.Length - 22.5F; bg3.localScale = scale; maxLenght = Mathf.Max(maxLenght, value3Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(4, data)); break; case ItemType.ARMOR: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); ArmorData ad = (ArmorData)data; value1.text = "Броня: <color=orange>" + ad.armorClass + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 22.5F; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(3, data)); break; case ItemType.GENERATOR: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); GeneratorData gd = (GeneratorData)data; value1.text = "Мощность: <color=orange>" + gd.maxEnergy + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 22.5F; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(3, data)); break; case ItemType.RADAR: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); pre4.gameObject.SetActive(true); bg4.gameObject.SetActive(true); value4.gameObject.SetActive(true); RadarData rd = (RadarData)data; value1.text = "Дальность: <color=orange>" + rd.range + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Питание: <color=cyan>" + data.energyNeeded + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 20.5f; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); value3.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value3Render); //value3.text.Length - 22.5F; bg3.localScale = scale; maxLenght = Mathf.Max(maxLenght, value3Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(4, data)); break; case ItemType.SHIELD: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); pre4.gameObject.SetActive(true); bg4.gameObject.SetActive(true); value4.gameObject.SetActive(true); pre5.gameObject.SetActive(true); bg5.gameObject.SetActive(true); value5.gameObject.SetActive(true); ShieldData sd = (ShieldData)data; value1.text = "Защита: <color=orange>" + sd.shieldLevel + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Перезарядка: <color=orange>" + sd.rechargeSpeed + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 22.5F; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); value3.text = "Питание: <color=cyan>" + data.energyNeeded + "</color>"; scale.x = calcMeshLength(value3Render); //value3.text.Length - 20.5f; bg3.localScale = scale; maxLenght = Mathf.Max(maxLenght, value3Render.bounds.size.x); value4.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value4Render); //value4.text.Length - 22.5F; bg4.localScale = scale; maxLenght = Mathf.Max(maxLenght, value4Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(5, data)); break; case ItemType.REPAIR_DROID: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); pre4.gameObject.SetActive(true); bg4.gameObject.SetActive(true); value4.gameObject.SetActive(true); RepairDroidData rdd = (RepairDroidData)data; value1.text = "Ремонт: <color=orange>" + rdd.repairSpeed + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Питание: <color=cyan>" + data.energyNeeded + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 20.5f; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); value3.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value3Render); //value3.text.Length - 22.5F; bg3.localScale = scale; maxLenght = Mathf.Max(maxLenght, value3Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(4, data)); break; case ItemType.HARVESTER: pre1.gameObject.SetActive(true); bg1.gameObject.SetActive(true); value1.gameObject.SetActive(true); pre2.gameObject.SetActive(true); bg2.gameObject.SetActive(true); value2.gameObject.SetActive(true); pre3.gameObject.SetActive(true); bg3.gameObject.SetActive(true); value3.gameObject.SetActive(true); HarvesterData hd = (HarvesterData)data; value1.text = "Поиск: <color=orange>" + hd.harvestTime + "</color>"; scale.x = calcMeshLength(value1Render); //value1.text.Length - 22.5f; bg1.localScale = scale; maxLenght = Mathf.Max(maxLenght, value1Render.bounds.size.x); value2.text = "Объём: <color=orange>" + data.volume.ToString("0.0") + "</color>"; scale.x = calcMeshLength(value2Render); //value2.text.Length - 22.5F; bg2.localScale = scale; maxLenght = Mathf.Max(maxLenght, value2Render.bounds.size.x); maxLenght = Mathf.Max(maxLenght, setCost(3, data)); break; } maxX = screenWidth - maxLenght - .5f; }
public void useSupply(SupplySlot slot) { if (slot.item != null) { SupplyData data = (SupplyData)slot.item.itemData; if (fightProcessor.canUseSupply(data.type)) { bool toPlayer = data.type != SupplyType.GRENADE_FLASH && data.type != SupplyType.GRENADE_PARALIZE; StatusEffect statusEffect = getStatusEffectByType(data.type.toStatusEffectType(), toPlayer); FightEffectType fightEffectType = data.type.toFightEffectType(); if (data.type.isMedkit()) { fightEffectPlayer.playEffect(fightEffectType, Player.heal(data.value)); } else if (data.type.isGrenade()) { fightEffectPlayer.playEffectOnEnemy(fightEffectType, 0); statusEffect.addStatus(data.value, data.duration); } else if (data.type.isInjection()) { fightEffectPlayer.playEffect(fightEffectType, data.value); statusEffect.addStatus(data.value, data.duration); } else { Debug.Log("Unknown status effect type"); } Vector3 effectPos = toPlayer? playerStatusStartPosition: enemyStatusStartPosition; int activeEffects = -1; //вычитаем добавляемый эффект effList = toPlayer? playerStatusEffects: enemyStatusEffects; for (int i = 0; i < effList.Count; i++) { if (effList[i].isFired) { activeEffects++; } } if (toPlayer) { effectPos.x += activeEffects * playerStatusStep; } else { effectPos.y += activeEffects * enemyStatusStep; } statusEffect.transform.localPosition = effectPos; fightProcessor.skipMove(); FightProcessor.FIGHT_ANIM_PLAYER_DONE = false; slot.takeItem().destroy(); } } }
new public static bool CanBuild() { SupplyData sData = GameObject.FindObjectOfType <SupplyData>(); return(sData.wood > 5 && sData.gold > 2); }