Пример #1
0
 public Upgrade(string head, string desc)
 {
     heading     = head;
     description = desc;
     enabled     = false;
     effect      = new UpgradeEffect();
 }
    public void LoadUpgrades(List <string> upgradeIds)
    {
        List <Upgrade> upgradesToLoad   = new List <Upgrade>();
        string         upgradesFilepath = Directory.GetCurrentDirectory() + "\\Upgrades\\Upgrades.xml";

        XDocument upgrades = XDocument.Load(upgradesFilepath);

        if (upgrades != null && upgrades.Descendants("Upgrade") != null)
        {
            List <XElement> upgradesToLoadXml = upgrades.Descendants("Upgrade")
                                                .Where(i => upgradeIds.Contains(i.Attribute("id").Value))
                                                .ToList();
            foreach (XElement upgradeElement in upgradesToLoadXml)
            {
                List <UpgradeEffect> effects = new List <UpgradeEffect>();
                foreach (XElement effectElement in upgradeElement.Descendants("UpgradeEffect").ToList())
                {
                    UpgradeEffect effectToLoad = new UpgradeEffect(effectElement.Attribute("statkey").Value,
                                                                   effectElement.Attribute("type").Value,
                                                                   float.Parse(effectElement.Attribute("value").Value));
                    effects.Add(effectToLoad);
                }

                Upgrade upgradetoLoad = new Upgrade(upgradeElement.Attribute("id").Value,
                                                    upgradeElement.Element("Name").Value,
                                                    upgradeElement.Element("Description").Value,
                                                    0f,
                                                    effects);
                upgradesToLoad.Add(upgradetoLoad);
            }
        }
        ApplyPermanentUpgrades(upgradesToLoad);
    }
Пример #3
0
 public Upgrade(string name, float cost, UpgradeEffect effect)
 {
     _name     = name;
     _cost     = cost;
     _effect   = effect;
     _isActive = false;
 }
 public void InitializeUpgrade(UpgradeEffect upgradeKind)
 {
     kind       = upgradeKind;
     buttonText = transform.GetChild(0).GetComponent <TextMeshProUGUI>();
     button     = GetComponent <Button>();
     UpdateButton();
     button.onClick.AddListener(OnClick);
 }
Пример #5
0
    public override void DrawCell(int index, int count = 0)
    {
        base.DrawCell(index, count);
        var           list     = sanctuaryPackage.GetBuildingUpgradeEffect();
        UpgradeEffect upEffect = list[index];

        nameLabel.text = upEffect.title;
        preLabel.text  = upEffect.preNum;
        nextLabel.text = upEffect.nextNum;
    }
Пример #6
0
        public void UpgradeEffectPtjCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetPtjCheck(PtjType.Bank, 21);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  13 00 00 00" +
                             "06 00 15 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #7
0
        public void UpgradeEffectSkillEffect()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetSkillEffect(SkillId.Smash, 1, 100, UpgradeValueType.Percent);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  1B 00 00 00  9B 01 64 00" +
                             "22 4E 01 00  0A 00 00 00  00 00 00 00  0A 00 00 00" +
                             "00 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #8
0
        public void UpgradeEffectMonthCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetMonthCheck(Month.Baltane);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  12 00 00 00" +
                             "02 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #9
0
        public void UpgradeEffectTitleCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetTitleCheck(TitleId.devCAT);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  11 00 00 00" +
                             "61 EA 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #10
0
        public void UpgradeEffectConditionCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetConditionCheck(20);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  10 00 00 00" +
                             "14 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #11
0
        public void UpgradeEffectBrokenCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetBrokenCheck(true);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  14 00 00 00" +
                             "01 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #12
0
        public void UpgradeEffectSupportCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetSupportCheck(SupportRace.Elf);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  15 00 00 00" +
                             "01 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #13
0
        private static string ToHex(UpgradeEffect effect)
        {
            var size = Marshal.SizeOf(effect);
            var arr  = new byte[size];
            var ptr  = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(effect, ptr, true);
            Marshal.Copy(ptr, arr, 0, size);
            Marshal.FreeHGlobal(ptr);

            return(BitConverter.ToString(arr).Replace("-", ""));
        }
Пример #14
0
        public void UpgradeEffectSummonCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetSummonCheck(UpgradeStat.Golem);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  18 00 00 00" +
                             "65 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));

            Assert.Throws(typeof(ArgumentException), () => effect.SetSummonCheck(UpgradeStat.STR));
        }
Пример #15
0
        public void UpgradeEffectStatCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetStatCheck(UpgradeStat.MP, UpgradeCheckType.LowerEqualThan, 500, UpgradeValueType.Percent);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  07 00 00 00" +
                             "02 01 F4 01"
                             ).Replace(" ", ""), ToHex(effect));

            Assert.Throws(typeof(ArgumentException), () => effect.SetStatCheck(UpgradeStat.MP, UpgradeCheckType.SkillRankGreaterThan, 500, UpgradeValueType.Percent));
        }
Пример #16
0
        public void UpgradeEffectSkillCheck()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetSkillCheck(SkillId.Smash, UpgradeCheckType.SkillRankGreaterThan, SkillRank.R9);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  0E 00 00 00" +
                             "22 4E 00 07"
                             ).Replace(" ", ""), ToHex(effect));

            Assert.Throws(typeof(ArgumentException), () => effect.SetSkillCheck(SkillId.Smash, UpgradeCheckType.WhenBroken, SkillRank.R9));
        }
Пример #17
0
    public void ApplyUpgrade(UpgradeEffect effect)
    {
        ballSpeed += effect.ballSpeed;
        ballReturnTime += effect.ballReturnTime;
        ballReturnTime += effect.ballReturnDelay;
        noOfBalls += effect.noOfBalls;
        moneyPK += effect.moneyMultiplier;

        if (!autoKick)
        {
            autoKick = effect.autoKick;
        }
    }
Пример #18
0
        public void UpgradeEffectTypes()
        {
            var effect = new UpgradeEffect(UpgradeType.Prefix);

            Assert.Equal((
                             "00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  0A 00 00 00" +
                             "00 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));

            effect = new UpgradeEffect(UpgradeType.Suffix);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  0A 00 00 00" +
                             "00 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #19
0
        public void UpgradeEffectStatEffect()
        {
            var effect = new UpgradeEffect(UpgradeType.Suffix);

            effect.SetStatEffect(UpgradeStat.STR, 20, UpgradeValueType.Fix);
            Assert.Equal((
                             "01 00 00 00  00 00 00 00  00 00 00 00  0A 03 14 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  0A 00 00 00" +
                             "00 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));

            effect.SetType(UpgradeType.Elemental);
            effect.SetStatEffect(UpgradeStat.Fire, 1, UpgradeValueType.Value);
            Assert.Equal((
                             "02 00 00 00  00 00 00 00  02 00 00 00  1B 00 01 00" +
                             "00 00 00 00  0A 00 00 00  00 00 00 00  0A 00 00 00" +
                             "00 00 00 00"
                             ).Replace(" ", ""), ToHex(effect));
        }
Пример #20
0
 public void CalculateBuildingUpgradeEffect(Building building, int preLevel)
 {
     if (preLevel >= 20)
     {
         return;
     }
     upgradeEffectList.Clear();
     GetBuildingAttribute(building, preLevel);
     for (int i = 0; i < attributeDataList.Count; i++)
     {
         UpgradeEffect upEffect = new UpgradeEffect();
         upEffect.title  = attributeDataList[i].name.ToString();
         upEffect.preNum = attributeDataList[i].value.ToString();
         upgradeEffectList.Add(upEffect);
     }
     GetBuildingAttribute(building, preLevel + 1);
     for (int i = 0; i < attributeDataList.Count; i++)
     {
         UpgradeEffect upEffect = upgradeEffectList[i];
         upEffect.nextNum = attributeDataList[i].value.ToString();
     }
 }
Пример #21
0
    void ApplyUpgradeEffect(UpgradeEffect effect)
    {
        switch (effect.parameter)
        {
        case UpgradeParameter.lineLength:
            peopleManager.maxLineLength = (int)ApplyOperationOnValue(effect.operation, effect.amount, peopleManager.maxLineLength);
            break;

        case UpgradeParameter.lineRefreshSpeed:
            peopleManager.lineAcceptanceRate = ApplyOperationOnValue(effect.operation, effect.amount, peopleManager.lineAcceptanceRate);
            break;

        case UpgradeParameter.numberOfCarsInEachTrain:
            trainManager.numberOfCars = (int)ApplyOperationOnValue(effect.operation, effect.amount, trainManager.numberOfCars);
            break;

        case UpgradeParameter.numberOfTrains:
            trainManager.idleTrainCapacity = (int)ApplyOperationOnValue(effect.operation, effect.amount, trainManager.idleTrainCapacity);
            break;

        case UpgradeParameter.redSpenderTypeChance:
            peopleManager.chanceOfRedSpender = ApplyOperationOnValue(effect.operation, effect.amount, peopleManager.chanceOfRedSpender);
            break;

        case UpgradeParameter.blueSpenderTypeChance:
            peopleManager.chanceOfBlueSpender = ApplyOperationOnValue(effect.operation, effect.amount, peopleManager.chanceOfBlueSpender);
            break;

        case UpgradeParameter.purpleSpenderTypeChance:
            peopleManager.chanceOfPurpleSpender = ApplyOperationOnValue(effect.operation, effect.amount, peopleManager.chanceOfPurpleSpender);
            break;

        case UpgradeParameter.rideExcitement:
            trackManager.rideExcitementMultiplier = ApplyOperationOnValue(effect.operation, effect.amount, trackManager.rideExcitementMultiplier);
            break;

        case UpgradeParameter.numberOfConcurentTrainsAllowedOnTrack:
            trainManager.activeTrainCapacity = (int)ApplyOperationOnValue(effect.operation, effect.amount, trainManager.activeTrainCapacity);
            break;

        case UpgradeParameter.trainCreationRate:
            trainManager.newTrainInterval = ApplyOperationOnValue(effect.operation, effect.amount, trainManager.newTrainInterval);
            break;

        case UpgradeParameter.unlockPhotoStation:
            trackManager.UnlockTrackType(TrackType.Photo);
            break;

        case UpgradeParameter.unlockBank:
            trackManager.UnlockTrackType(TrackType.Bank);
            break;

        case UpgradeParameter.loopSlowdown:
            trackManager.ApplyUpgrade(TrackTypeUpgrade.LoopSlowdown);
            break;

        case UpgradeParameter.unlockTrainOMatic:
            trackManager.ApplyUpgrade(TrackTypeUpgrade.TrainOMatic);
            break;

        case UpgradeParameter.greenMoneyValue:
            moneyManager.ApplyUpgrade(UpgradeParameter.greenMoneyValue);
            break;

        case UpgradeParameter.redMoneyValue:
            moneyManager.ApplyUpgrade(UpgradeParameter.redMoneyValue);
            break;

        case UpgradeParameter.blueMoneyValue:
            moneyManager.ApplyUpgrade(UpgradeParameter.blueMoneyValue);
            break;

        case UpgradeParameter.purpleMoneyValue:
            moneyManager.ApplyUpgrade(UpgradeParameter.purpleMoneyValue);
            break;

        case UpgradeParameter.winTheGame:
            SceneManager.LoadScene("WinScene", LoadSceneMode.Single);
            break;
        }
    }
    private void ApplySetEffect(UpgradeEffect effect)
    {
        MainCharacter mainCharacter = GetComponent <MainCharacter>();
        Health        health        = GetComponent <Health>();
        Armor         armor         = GetComponent <Armor>();

        switch (effect.GameStatKey)
        {
        case GameStats.STAT_HEALTH:
            if (health)
            {
                health.MaximumHealth = effect.Value;
            }
            break;

        case GameStats.STAT_ARMOR:
            if (armor)
            {
                armor.MaximumArmor = effect.Value;
            }
            break;

        case GameStats.STAT_ARMOR_ABSORPTION:
            if (armor)
            {
                armor.ArmorAbsorption = effect.Value;
            }
            break;

        case GameStats.STAT_ARMOR_DECAY_AMOUNT:
            if (armor)
            {
                armor.ArmorDecayAmount = effect.Value;
            }
            break;

        case GameStats.STAT_ARMOR_DECAY_RATE:
            if (armor)
            {
                armor.ArmorDecayRate = effect.Value;
            }
            break;

        case GameStats.STAT_ARMOR_FREE:
            if (armor)
            {
                armor.FreeArmor = effect.Value;
            }
            break;

        case GameStats.STAT_MOVE_SPEED:
            if (mainCharacter)
            {
                mainCharacter.MoveSpeed = effect.Value;
            }
            break;

        case GameStats.STAT_JUMP_SPEED:
            if (mainCharacter)
            {
                mainCharacter.JumpVerticalSpeed = effect.Value;
            }
            break;

        case GameStats.STAT_ATTACK_SPEED:
            if (mainCharacter)
            {
                mainCharacter.AttackSpeed = effect.Value;
            }
            break;

        case GameStats.STAT_MIDAIR_REVERSE_SPEED:
            if (mainCharacter)
            {
                mainCharacter.MidairReverseSpeed = effect.Value;
            }
            break;

        default:
            throw new StatNotFoundException("Stat not found: " + effect.GameStatKey);
        }
    }
Пример #23
0
    protected override async Task Talk()
    {
        Msg("A... a customer? Uhm, okay, what... what can I do for you?<br/>Sorry, I'm new to this.", Button("Upgrade item", "@upgrade"), Button("End conversation", "@end"));

        if (await Select() == "@upgrade")
        {
            Msg("<selectitem stringid='*/equip/*' />");
            var select = await Select();

            if (select != "@cancel")
            {
                var entityId = Convert.ToInt64(select.Substring("@select:".Length));
                var item     = Player.Inventory.GetItem(entityId);
                if (item != null)
                {
                    Msg("This one...? Of course, uhm, which upgrade would you like?");
                    Msg(List("Select Upgrade", Button("500 STR", "@str"), Button("5 INT", "@int"), Button("5 DEX", "@dex"), Button("5 Will", "@will"), Button("5 Luck", "@luck")));

                    UpgradeStat stat;
                    short       value = 5;
                    switch (await Select())
                    {
                    default:
                    case "@str": stat = UpgradeStat.STR; value = 500; break;

                    case "@int": stat = UpgradeStat.Intelligence; break;

                    case "@dex": stat = UpgradeStat.Dexterity; break;

                    case "@will": stat = UpgradeStat.Will; break;

                    case "@luck": stat = UpgradeStat.Luck; break;
                    }

                    var effect = new UpgradeEffect(UpgradeType.ItemAttribute);
                    effect.SetStatEffect(stat, value, UpgradeValueType.Value);

                    if (stat == UpgradeStat.STR)
                    {
                        Msg("Heh, that's my favorite upgrade as well.<br/>Let's see.", Button("Continue"));
                    }
                    else
                    {
                        Msg("Eh...? But... nevermind, you surely know what you're doing!<br/>Let's see.", Button("Continue"));
                    }

                    await Select();

                    for (int i = 0; i < 3; ++i)
                    {
                        Task.Delay(i * 500).ContinueWith(_ => Send.PlaySound(Player, "data/sound/blacksmith_click_best.wav"));
                        Task.Delay(i * 500 + 250).ContinueWith(_ => Send.PlaySound(Player, "data/sound/blacksmith_click_normal.wav"));
                        Task.Delay(i * 500 + 350).ContinueWith(_ => Send.PlaySound(Player, "data/sound/blacksmith_click_normal.wav"));
                    }
                    Task.Delay(1750).ContinueWith(_ => Send.PlaySound(Player, "data/sound/emotion_fail.wav"));
                    Msg("...<autopass duration='500'/><p/>... ...<autopass duration='500'/><p/>... ... ...<autopass duration='750'/><p/>Uh-oh...<br/>Uhm, could you wait a second?", Button("..."));
                    await Select();

                    for (int i = 0; i < 10; ++i)
                    {
                        Task.Delay(i * 250).ContinueWith(_ => Send.PlaySound(Player, "data/sound/blacksmith_click_best.wav"));
                    }
                    Task.Delay(3000).ContinueWith(_ => Send.PlaySound(Player, "data/sound/emotion_success.wav"));
                    Msg("...<autopass duration='3000'/><p/>There it is, good as new, and with your upgrade!<br/>Have a good day!");

                    item.AddUpgradeEffect(effect);
                    Send.ItemUpdate(Player, item);

                    End();
                }
            }
        }

        Close(Hide.None, "(phew) See you.");
    }
Пример #24
0
    void OnWizardCreate()
    {
        foreach (GameObject go in _weaponModels)
        {
            string     path    = AssetDatabase.GetAssetPath(go);
            GameObject inst    = GameObject.Instantiate(go, Vector3.zero, Quaternion.identity) as GameObject;
            string     matPath = path.ToLower().Replace(".fbx", ".mat");
            matPath = matPath.Replace("_left", "");
            matPath = matPath.Replace("_right", "");
            Material mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;
            // collect mesh renderers. Most of weapons has only 1 renderer.
            Renderer [] renderers = inst.GetComponentsInChildren <Renderer>();
            // get max bounding box.
            Bounds bnd = renderers[0].bounds;
            for (int i = 1; i < renderers.Length; ++i)
            {
                if (renderers[i].gameObject.tag == "")
                {
                    bnd.Encapsulate(renderers[i].bounds);
                }
            }
            // add blade slide.
            if (_addBladeSlide && path.Contains("_mid.") && renderers.Length > 0)
            {
                BladeSlide bs = inst.AddComponent <BladeSlide>();
                GameObject a  = new GameObject("A");
                a.transform.parent        = inst.transform;
                a.transform.localPosition = Vector3.forward * bnd.max.z;
                GameObject b = new GameObject("B");
                b.transform.parent        = inst.transform;
                b.transform.localPosition = Vector3.forward * (bnd.min.z + bnd.size.z * 0.25f);
                bs.PointA        = a.transform;
                bs.PointB        = b.transform;
                bs.BladeMaterial = AssetDatabase.LoadAssetAtPath("Assets/Weapon/Common/Blade/swing_default.mat", typeof(Material)) as Material;
            }

            if (path.Contains("_mid."))
            {
                // add physics collider & callback script.
                GameObject weaponCollider = new GameObject("Collider");
                bool       isHero         = false;
                if (path.StartsWith("Assets/Weapon/Warrior/") ||
                    path.StartsWith("Assets/Weapon/Monk/") ||
                    path.StartsWith("Assets/Weapon/Mage/"))
                {
                    isHero = true;
                }
                if (isHero)
                {
                    weaponCollider.AddComponent <PlayerMessageReceiver>();
                }
                else
                {
                    weaponCollider.AddComponent <MessageReciever>();
                }
                BoxCollider bc = weaponCollider.AddComponent <BoxCollider>();
                bc.center    = bnd.center;
                bc.size      = bnd.size;
                bc.isTrigger = true;
                GameObject oldGo = AssetDatabase.LoadAssetAtPath(path.Replace(".fbx", ".prefab"), typeof(GameObject)) as GameObject;
                if (oldGo != null)
                {
                    oldGo = GameObject.Instantiate(oldGo) as GameObject;
                    BoxCollider oldBc = oldGo.GetComponentInChildren <BoxCollider>();
                    if (oldBc != null)
                    {
                        bc.center = oldBc.center;
                        bc.size   = oldBc.size;
                    }
                    GameObject.DestroyImmediate(oldGo);
                }
                weaponCollider.transform.parent        = inst.transform;
                weaponCollider.transform.localPosition = Vector3.zero;
                weaponCollider.transform.localRotation = Quaternion.identity;
                weaponCollider.transform.localScale    = Vector3.one;

                if (isHero)
                {
                    // hook upgrade effect.
                    foreach (GameObject upgrade in _upgradeEffects)
                    {
                        GameObject    u             = GameObject.Instantiate(upgrade) as GameObject;
                        bool          addEffect     = false;            // decide whether to add this effect.
                        Vector3       localPosition = Vector3.forward * (bnd.center.z + bnd.size.z * 0.5f);
                        Quaternion    localRot      = Quaternion.identity;
                        Vector3       localScale    = Vector3.one;
                        UpgradeEffect ue            = u.GetComponent <UpgradeEffect>();
                        // ignore this object if no UpgradeEffect component attached on.
                        if (ue != null)
                        {
                            addEffect = true;
                            // for Shadow Effect, renderer of weapon is needed
                            if (ue is UpgradeShadowEffect)
                            {
                                addEffect = (renderers.Length > 0);
                                if (renderers.Length > 0)
                                {
                                    UpgradeShadowEffect use = ue as UpgradeShadowEffect;
                                    use._reference = renderers[0];
                                }
                            }
                        }
                        // if effect is allowed to add, hang it under weapon.
                        if (addEffect)
                        {
                            u.transform.parent        = inst.transform;
                            u.transform.localPosition = localPosition;
                            u.transform.localRotation = localRot;
                            u.transform.localScale    = localScale;
                        }
                        // otherwise destroy this temprary object.
                        else
                        {
                            GameObject.DestroyImmediate(u);
                        }
                    }
                }
            }
            // set material and layer for renderable objects.
            foreach (Renderer r in renderers)
            {
                if (r.gameObject.tag == "Untagged")
                {
                    r.sharedMaterial   = mat;
                    r.gameObject.layer = LayerMask.NameToLayer("CHARACTER");
                }
            }
            PrefabUtility.CreatePrefab(path.ToLower().Replace(".fbx", ".prefab"), inst);
            DestroyImmediate(inst);
        }
    }
 public void LoadNewUpgrade(Upgrade newUpgrade)
 {
     headingDisplay.text     = newUpgrade.heading;
     descriptionDisplay.text = newUpgrade.description;
     effect = newUpgrade.effect;
 }
Пример #26
0
        public UpgradeEffect GetUpgradeEffect(Random rnd)
        {
            var effect = new UpgradeEffect(this.Type);

            // Stat effect
            if (this.Stat != null)
            {
                // Stat
                var stat = (UpgradeStat)this.Stat;

                // Value type
                UpgradeValueType valueType;
                if (this.Value.EndsWith("%"))
                {
                    valueType = UpgradeValueType.Percent;
                }
                else
                {
                    valueType = UpgradeValueType.Value;
                }

                // Value
                if (this.Value == null)
                {
                    throw new NullReferenceException("Value can't be empty if Stat is set.");
                }

                var match = _valueRegex.Match(this.Value);
                if (!match.Success)
                {
                    throw new FormatException("Invalid value format: " + this.Value);
                }

                var min  = Convert.ToInt32(match.Groups["min"].Value);
                var maxs = match.Groups["max"].Value;
                var max  = (maxs == "" ? min : (int)Math.Max(min, Convert.ToInt32(maxs)));
                if (match.Groups["sign"].Value == "-")
                {
                    // For negative numbers min and max must be reversed,
                    // e.g. -1~2 becomes "from -2 to -1".
                    var temp = min;
                    min = -max;
                    max = -temp;
                }
                var value = (short)rnd.Next(min, max + 1);

                // Set
                effect.SetStatEffect(stat, value, valueType);
            }

            // Stat check
            if (this.Check == "gte" || this.Check == "lte" || this.Check == "gt" || this.Check == "lt" || this.Check == "equal")
            {
                // Check type
                UpgradeCheckType checkType;
                switch (this.Check)
                {
                case "gte": checkType = UpgradeCheckType.GreaterEqualThan; break;

                case "lte": checkType = UpgradeCheckType.LowerEqualThan; break;

                case "gt": checkType = UpgradeCheckType.GreaterThan; break;

                case "lt": checkType = UpgradeCheckType.LowerThan; break;

                case "equal": checkType = UpgradeCheckType.Equal; break;

                default: throw new NotSupportedException("Unknown check type: " + this.Check);
                }

                // Stat
                var stat = (UpgradeStat)Enum.Parse(typeof(UpgradeStat), this.If);

                // Value type
                var valueType = UpgradeValueType.Value;
                if (this.CheckValue.EndsWith("%"))
                {
                    valueType = UpgradeValueType.Percent;
                }

                // Value
                var value = short.Parse(this.CheckValue.TrimEnd('%'));

                // Set
                effect.SetStatCheck(stat, checkType, value, valueType);
            }
            // Skill check
            else if (this.Check == "rank_gte" || this.Check == "rank_lte" || this.Check == "rank_equal")
            {
                // Check type
                UpgradeCheckType checkType;
                switch (this.Check)
                {
                case "rank_gte": checkType = UpgradeCheckType.SkillRankGreaterThan; break;

                case "rank_lte": checkType = UpgradeCheckType.SkillRankLowerThan; break;

                case "rank_equal": checkType = UpgradeCheckType.SkillRankEqual; break;

                default: throw new NotSupportedException("Unknown check type: " + this.Check);
                }

                // Skill id
                var skillId = (SkillId)Enum.Parse(typeof(SkillId), this.If);

                // Rank
                var rank = (this.CheckValue == "N" ? SkillRank.Novice : (SkillRank)(16 - Convert.ToInt32(this.CheckValue, 16)));

                // Set
                effect.SetSkillCheck(skillId, checkType, rank);
            }
            // Ptj check
            else if (this.Check == "ptj_gte")
            {
                // Ptj type
                var ptjType = (PtjType)Enum.Parse(typeof(PtjType), this.If);

                // Count
                var count = int.Parse(this.CheckValue);

                // Set
                effect.SetPtjCheck(ptjType, count);
            }
            // Broken check
            else if (this.If == "intact" || this.If == "broken")
            {
                var broken = (this.If == "intact" ? false : true);
                effect.SetBrokenCheck(broken);
            }
            // Title check
            else if (this.If == "title")
            {
                var titleId = int.Parse(this.CheckValue);
                effect.SetTitleCheck(titleId);
            }
            // Condition check
            else if (this.If == "condition")
            {
                var condition = int.Parse(this.CheckValue);
                effect.SetConditionCheck(condition);
            }
            // Month check
            else if (this.If == "month")
            {
                var month = (Month)Enum.Parse(typeof(Month), this.CheckValue);
                effect.SetMonthCheck(month);
            }
            // Summon check
            else if (this.If == "summoned")
            {
                var summonStat = (UpgradeStat)Enum.Parse(typeof(UpgradeStat), this.CheckValue);
                effect.SetSummonCheck(summonStat);
            }
            // Support check
            else if (this.If == "supporting")
            {
                var race = (SupportRace)Enum.Parse(typeof(SupportRace), this.CheckValue);
                effect.SetSupportCheck(race);
            }

            return(effect);
        }