示例#1
0
        public override bool GetValue()
        {
            if (Application.isPlaying)
            {
                string                fromId = GlobalLib.ReplaceText(fromInfoId);
                string                toId   = GlobalLib.ReplaceText(toInfoId);
                CharacterInfoData     from   = Game.GameData.Character[fromId];
                CharacterInfoData     to     = Game.GameData.Character[toId];
                CharacterExteriorData toEx   = Game.GameData.Exterior[toId];
                if (from == null || to == null || toEx == null || from == to)
                {
                    return(false);
                }

                float totalDelta = 0;
                for (int i = 0; i < propertyTypes.Length; ++i)
                {
                    var propertyType = propertyTypes[i];
                    totalDelta += from.GetUpgradeableProperty(propertyType) - to.GetUpgradeableProperty(propertyType);
                }
                float scale = scalar * (2f - totalDelta / 2000f);

                List <string> list = new List <string>();
                for (int i = 0; i < propertyTypes.Length; ++i)
                {
                    var propertyType = propertyTypes[i];
                    int delta        = from.GetUpgradeableProperty(propertyType) - to.GetUpgradeableProperty(propertyType) + baseValue;
                    int exp          = (int)Mathf.Max(0f, delta * scale);
                    if (exp >= 100)
                    {
                        to.AddUpgradeablePropertyExp(propertyType, exp);
                        to.UpgradeProperty(false);
                        list.Add(string.Format("{0}提升{1}", Game.Data.Get <StringTable>(messages[i]).Text, exp / 100));
                    }
                }
                if (list.Count > 0)
                {
                    Game.UI.AddMessage(string.Format("{0}经切磋,{1}", toEx.FullName(), string.Join(",", list)), UIPromptMessage.PromptType.Normal);
                }
                else
                {
                    Game.UI.AddMessage(string.Format("{0}由于四维超出对手过多,切磋后未获提升", toEx.FullName()), UIPromptMessage.PromptType.Normal);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        // 升级函数提取
        public static int CalculateNurturanceExp(CharacterInfoData data, CharacterUpgradablePropertyTable _property, int require_status)
        {
            int player_status = 4000;

            if (_property <= CharacterUpgradablePropertyTable.Vit)
            {
                if (_property == CharacterUpgradablePropertyTable.Str)
                {
                    player_status = data.GetUpgradeableProperty(CharacterUpgradableProperty.Str);
                }
                if (_property == CharacterUpgradablePropertyTable.Vit)
                {
                    player_status = data.GetUpgradeableProperty(CharacterUpgradableProperty.Vit);
                }
            }
            else
            {
                if (_property == CharacterUpgradablePropertyTable.Dex)
                {
                    player_status = data.GetUpgradeableProperty(CharacterUpgradableProperty.Dex);
                }
                if (_property == CharacterUpgradablePropertyTable.Spi)
                {
                    player_status = data.GetUpgradeableProperty(CharacterUpgradableProperty.Spi);
                }
                if (_property == CharacterUpgradablePropertyTable.Sum)
                {
                    player_status = data.GetUpgradeableProperty(CharacterUpgradableProperty.Str) + data.GetUpgradeableProperty(CharacterUpgradableProperty.Vit) + data.GetUpgradeableProperty(CharacterUpgradableProperty.Dex) + data.GetUpgradeableProperty(CharacterUpgradableProperty.Spi);
                }
            }
            return(Mathf.Clamp(Game.Data.Get <GameFormula>("skill_exp").EvaluateToInt(new Dictionary <string, int>
            {
                {
                    "player_status",
                    player_status
                },
                {
                    "require_status",
                    require_status
                }
            }), 25, 900));
        }
        //记录攻击者和防御者的属性
        public static void AttachBattleComputerProperty(CharacterInfoData attacker, CharacterInfoData defender)
        {
            Heluo.Logger.LogError("AttachBattleComputerProperty start");
            BattleComputer        battleComputer         = Singleton <BattleComputer> .Instance;
            BattleFormulaProperty BattleComputerProperty = Traverse.Create(battleComputer).Field("BattleComputerProperty").GetValue <BattleFormulaProperty>();
            BattleComputerFormula BattleComputerFormula  = Traverse.Create(battleComputer).Field("BattleComputerFormula").GetValue <BattleComputerFormula>();

            BattleComputerProperty.Clear();
            foreach (object obj in Enum.GetValues(typeof(NurturanceProperty)))
            {
                NurturanceProperty prop = (NurturanceProperty)obj;
                string             key  = string.Format("attacker_{0}", prop.ToString().ToLower());
                int    value            = attacker.GetUpgradeableProperty((CharacterUpgradableProperty)obj);
                string key2             = string.Format("defender_{0}", prop.ToString().ToLower());
                int    value2           = defender.GetUpgradeableProperty((CharacterUpgradableProperty)obj);
                BattleComputerProperty[key]  = value;
                BattleComputerProperty[key2] = value2;
                BattleComputerProperty[prop.ToString().ToLower()] = value;
            }
            foreach (object obj2 in Enum.GetValues(typeof(BattleProperty)))
            {
                BattleProperty battleProperty  = (BattleProperty)obj2;
                string         format          = "attacker_{0}";
                BattleProperty battleProperty2 = battleProperty;
                string         key3            = string.Format(format, battleProperty2.ToString().ToLower());
                int            value3          = attacker.Property[(CharacterProperty)obj2].Value;
                string         format2         = "defender_{0}";
                battleProperty2 = battleProperty;
                string key4   = string.Format(format2, battleProperty2.ToString().ToLower());
                int    value4 = defender.Property[(CharacterProperty)obj2].Value;
                BattleComputerProperty[key3] = value3;
                BattleComputerProperty[key4] = value4;
                if (battleProperty == BattleProperty.Move)
                {
                    break;
                }
            }

            BattleComputerProperty["attacker_element"] = (int)attacker.Element;
            BattleComputerProperty["defender_element"] = (int)defender.Element;

            BattleComputerProperty["defender_max_hp"] = defender.Property[CharacterProperty.Max_HP].Value;
            float num = BattleComputerFormula["basic_attack_of_counter"].Evaluate(BattleComputerProperty.GetDictionary());

            BattleComputerProperty.Add("basic_attack_of_counter", (int)num);

            Heluo.Logger.LogError("AttachBattleComputerProperty end");
        }
示例#4
0
        private static bool AddLuaParams(Script script, T item)
        {
            if (!UserData.IsTypeRegistered(typeof(T)))
            {
                UserData.RegisterType(typeof(T));
            }
            if (item.GetType() != typeof(Npc))
            {
                script.Globals["item"] = item;
            }
            else
            {
                // 传NPC信息没太大用处,改传CharacterInfo的信息
                Npc npc = item as Npc;
                try
                {
                    CharacterExteriorData exterior = null;
                    CharacterInfoData     info     = null;
                    if (!npc.ExteriorId.IsNullOrEmpty())
                    {
                        exterior = Game.GameData.Exterior[npc.ExteriorId];
                    }
                    if (exterior != null && !exterior.InfoId.IsNullOrEmpty())
                    {
                        info = Game.GameData.Character[exterior.InfoId];
                    }
                    else if (!npc.CharacterInfoId.IsNullOrEmpty())
                    {
                        info = Game.GameData.Character[npc.CharacterInfoId];
                    }

                    if (info == null || info.Id.IsNullOrEmpty())
                    {
                        return(false);
                    }
                    if (info.Property[CharacterProperty.Max_HP].Value <= 0)
                    {
                        return(false);
                    }

                    if (!UserData.IsTypeRegistered <CharacterInfoData>())
                    {
                        UserData.RegisterType <CharacterInfoData>(InteropAccessMode.Default, null);
                    }
                    script.Globals["item"] = info;

                    foreach (object obj in Enum.GetValues(typeof(CharacterUpgradableProperty)))
                    {
                        CharacterUpgradableProperty prop = (CharacterUpgradableProperty)obj;
                        int value = info.GetUpgradeableProperty(prop);
                        script.Globals[obj.ToString().ToLower()] = value;
                    }
                    foreach (object obj2 in Enum.GetValues(typeof(CharacterProperty)))
                    {
                        CharacterProperty prop2 = (CharacterProperty)obj2;
                        int value2 = info.Property[prop2].Value;
                        script.Globals[obj2.ToString().ToLower()] = value2;
                    }
                }
                catch
                {
                    Console.WriteLine(string.Format("NPC信息出错 npc={0}, exId={1}, infoId={2}", npc.Id, npc.ExteriorId, npc.CharacterInfoId));
                    return(false);
                }
            }
            return(true);
        }