Esempio n. 1
0
    public static RepairDroidData createRepairDroidData(RepairDroidType type)
    {
        ItemQuality quality = randQuality();
        float       level   = randLevel();

        int repairSpeed = Mathf.RoundToInt(type.repairSpeed() * level * qualityMultiplier(quality));

        RepairDroidData data = new RepairDroidData(quality, level, type, repairSpeed);

        data.initCommons(calculateCost(data), calculateEnergy(data));

        return(data);
    }
Esempio n. 2
0
    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;
    }
Esempio n. 3
0
    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);
    }
Esempio n. 4
0
    private List <Item> sortList(List <Item> list, ItemType type)
    {
        SortedDictionary <long, Item> weights = new SortedDictionary <long, Item>();
        long weight = 0;

        foreach (Item item in list)
        {
            if (type == ItemType.WEAPON)
            {
                WeaponData data = (WeaponData)item.itemData;
                switch (data.type)
                {
                case WeaponType.BLASTER: weight = 1000000; break;

                case WeaponType.PLASMER: weight = 2000000; break;

                case WeaponType.CHARGER: weight = 3000000; break;

                case WeaponType.EMITTER: weight = 4000000; break;

                case WeaponType.WAVER: weight = 5000000; break;

                case WeaponType.LAUNCHER: weight = 6000000; break;

                case WeaponType.SUPPRESSOR: weight = 7000000; break;

                default: Debug.Log("Неизвестный тип оружия"); break;
                }
                weight += item.cost;
            }
            else if (type == ItemType.HAND_WEAPON)
            {
                HandWeaponData data = (HandWeaponData)item.itemData;
                weight = data.maxDamage * 1000000 + data.cost;
            }
            else if (type == ItemType.BODY_ARMOR)
            {
                BodyArmorData data = (BodyArmorData)item.itemData;
                weight = data.armorClass * 1000000 + data.cost;
            }
            else if (type == ItemType.ENGINE)
            {
                EngineData data = (EngineData)item.itemData;
                weight = Mathf.RoundToInt(data.power * 1000);
            }
            else if (type == ItemType.ARMOR)
            {
                ArmorData data = (ArmorData)item.itemData;
                weight = data.armorClass * 1000000 + data.cost;
            }
            else if (type == ItemType.GENERATOR)
            {
                GeneratorData data = (GeneratorData)item.itemData;
                weight = data.maxEnergy * 1000000 + data.cost;
            }
            else if (type == ItemType.RADAR)
            {
                RadarData data = (RadarData)item.itemData;
                weight = data.range * 1000000 + data.cost;
            }
            else if (type == ItemType.SHIELD)
            {
                ShieldData data = (ShieldData)item.itemData;
                weight = data.shieldLevel * 1000000 + data.cost;
            }
            else if (type == ItemType.REPAIR_DROID)
            {
                RepairDroidData data = (RepairDroidData)item.itemData;
                weight = data.repairSpeed * 1000000 + data.cost;
            }
            else if (type == ItemType.HARVESTER)
            {
                HarvesterData data = (HarvesterData)item.itemData;
                weight = 1000000 - data.harvestTime;
            }
            else if (type == ItemType.GOODS)
            {
                weight = item.itemData.cost;
            }
            else if (type == ItemType.SUPPLY)
            {
                weight = item.itemData.sortWeight + item.cost;
            }
            else
            {
                Debug.Log("Unknown item: " + item.name);
            }
            while (weights.ContainsKey(weight))
            {
                weight++;
            }
            weights.Add(weight, item);
        }

        list.Clear();

        foreach (KeyValuePair <long, Item> pair in weights)
        {
            list.Add(pair.Value);
        }
        list.Reverse();

        return(list);
    }