コード例 #1
0
ファイル: WorldGeneration.cs プロジェクト: Tonaplo/RPG
        /// <summary>
        /// This method generates an NPC, along with a random AI
        /// </summary>
        /// <param name="_npcName">The name of the NPC - set to null for generated name</param>
        /// <param name="_npcLevel">The level the NPC should be</param>
        /// <param name="_npcType">The Monster Type of the NPC - set to null for generated type</param>
        /// <param name="_numberOfChars">The amount of targets, that the NPC should go for</param>
        /// <returns></returns>
        public static Core.Units.NPC GenerateNPC(string _npcName, int _npcLevel, int _difficulty, EnumMonsterType _npcType, int numberOfChars)
        {
            int realLevel = _npcLevel + _difficulty;
            int expGained = 0;
            int hp = 0;
            if (realLevel <= 1)
                hp = (int)(5 * numberOfChars*1.2 * ((_npcLevel/10)+1));
            else if (realLevel == 2)
                hp = (int)((realLevel * 4) * numberOfChars * 1.2 + (realLevel / 10) * 2);
            else
                hp = (int)((realLevel * (realLevel - 1)) * numberOfChars * 1.2 + (_npcLevel / 10) * 2);

            if (_difficulty == -4)
                expGained = 0;
            else if (_difficulty == -2)
                expGained = (int)(realLevel * 0.5);
            else if (_difficulty == 0)
                expGained = realLevel;
            else if (_difficulty == 2)
                expGained = (int)(realLevel * 1.2);
            else if (_difficulty == 4)
                expGained = (int)(realLevel * 1.5);

            expGained *= (int)(0.9 + (double)numberOfChars/6.0);

            Core.Units.NPC returnedNPC = new Core.Units.NPC(_npcName, realLevel, hp, hp, _npcType, expGained, null, null);

            if (_npcType == EnumMonsterType.Null)
                returnedNPC.TypeOfNPC = GenerateMonterType();

            if (_npcName == null)
                returnedNPC.UnitName = GenerateMonterName(returnedNPC.TypeOfNPC);

            return returnedNPC;
        }
コード例 #2
0
        /// <summary>
        /// The Main constructor for the NPCs.
        /// </summary>
        /// <param name="_name">The name of the NPC</param>
        /// <param name="_level">The level of the NPC. This value also indicates how good the loot the NPC drops will be</param>
        /// <param name="_basehp">The BASE amount of health of the NPC</param>
        /// <param name="_basemana">The BASE amount of mana of the NPC</param>
        /// <param name="_curhp">The CURRENT amount of health of the NPC</param>
        /// <param name="_curmana"> The CURRENT amount of mana of the NPC</param>
        /// <param name="_npctype">The type of the NPC</param>
        /// <param name="_xpGranted">How much Experience the NPC will grant the player when it is killed</param>
        /// <param name="_armor">The armor of the NPC</param>
        /// <param name="_meleeattack">The meleeattack damage of the NPC</param>
        /// <param name="_pa">The Passive Abilities of the NPC</param>
        /// <param name="_aa">The Activate Abilities of the NPC</param>
        /// <param name="_loot">The loot the NPC will drop. NOTE: Only include EPOCHAL items here, as other drops will be auto generated</param>
        public NPC(string _name, int _level, int _basehp, int _curhp, EnumMonsterType _npctype, int _xpGranted, List <Abilities.ActiveAbility> _pa, List <Abilities.ActiveAbility> _aa)
            : base(_name, _level, _basehp, _curhp)
        {
            this.typeOfNPC            = _npctype;
            this.UnitActiveAbilities  = _aa;
            this.UnitPassiveAbilities = _pa;
            if (_xpGranted > 0)
            {
                this.experienceYielded = 3 * _xpGranted;
            }
            else
            {
                this.experienceYielded = 3;
            }

            if (_pa == null)
            {
                this.UnitPassiveAbilities = new List <Abilities.ActiveAbility>();
            }
            else
            {
                this.UnitPassiveAbilities = _pa;
            }

            if (_aa == null)
            {
                this.UnitActiveAbilities = new List <Abilities.ActiveAbility>();
            }
            else
            {
                this.UnitActiveAbilities = _aa;
            }
        }
コード例 #3
0
 public override void InitiateQuest(Player _player)
 {
     monsterType       = Function.PlayerQuestHandler.ReturnRandomMonsterType();
     this.currentValue = 0;
     this.finalValue   = 3;
     this.questText    = "Defeat 3 " + monsterType + " of Very Easy difficulty";
 }
コード例 #4
0
        public override void UpdateQuest(Player _player, int _difficulty, NPC _enemy, int _healingDone, int _damageDone, double _charPercent, List <EnumCharClass> _class, bool battleWasWon)
        {
            if (monsterType == null)
            {
                monsterType = Function.PlayerQuestHandler.ReturnRandomMonsterType();
            }
            this.questText = "Defeat 3 " + monsterType + " of Very Hard difficulty";

            if (_difficulty == 4 && monsterType == _enemy.TypeOfNPC && battleWasWon)
            {
                this.currentValue++;
                if (currentValue == finalValue)
                {
                    this.EndQuest(_player);
                }
            }
        }
コード例 #5
0
ファイル: NPC.cs プロジェクト: Tonaplo/RPG
        /// <summary>
        /// The Main constructor for the NPCs.
        /// </summary>
        /// <param name="_name">The name of the NPC</param>
        /// <param name="_level">The level of the NPC. This value also indicates how good the loot the NPC drops will be</param>
        /// <param name="_basehp">The BASE amount of health of the NPC</param>
        /// <param name="_basemana">The BASE amount of mana of the NPC</param>
        /// <param name="_curhp">The CURRENT amount of health of the NPC</param>
        /// <param name="_curmana"> The CURRENT amount of mana of the NPC</param>
        /// <param name="_npctype">The type of the NPC</param>
        /// <param name="_xpGranted">How much Experience the NPC will grant the player when it is killed</param>
        /// <param name="_armor">The armor of the NPC</param>
        /// <param name="_meleeattack">The meleeattack damage of the NPC</param>
        /// <param name="_pa">The Passive Abilities of the NPC</param>
        /// <param name="_aa">The Activate Abilities of the NPC</param>
        /// <param name="_loot">The loot the NPC will drop. NOTE: Only include EPOCHAL items here, as other drops will be auto generated</param>
        public NPC(string _name, int _level, int _basehp, int _curhp, EnumMonsterType _npctype, int _xpGranted, List<Abilities.ActiveAbility> _pa, List<Abilities.ActiveAbility> _aa)
            : base(_name, _level, _basehp, _curhp)
        {
            this.typeOfNPC = _npctype;
            this.UnitActiveAbilities = _aa;
            this.UnitPassiveAbilities = _pa;
            if (_xpGranted > 0)
                this.experienceYielded = 3*_xpGranted;
            else
                this.experienceYielded = 3;

            if (_pa == null)
                this.UnitPassiveAbilities = new List<Abilities.ActiveAbility>();
            else
                this.UnitPassiveAbilities = _pa;

            if (_aa == null)
                this.UnitActiveAbilities = new List<Abilities.ActiveAbility>();
            else
                this.UnitActiveAbilities = _aa;
        }
コード例 #6
0
        /// <summary>
        /// This function generates a montername based on the type of the monster
        /// NOTE: Humanoids and undead share the same names.
        /// </summary>
        /// <param name="_npcType">The type of NPC being named</param>
        /// <returns>The new name of the NPC</returns>
        private static string GenerateMonterName(EnumMonsterType _npcType)
        {
            string _name = "";

            switch (_npcType)
            {
            case EnumMonsterType.Dragon:
                _name += dragonNames[r.Next(dragonNames.Count - 1)];
                break;

            case EnumMonsterType.Humanoid:
                _name += humanoidNames[r.Next(humanoidNames.Count - 1)];
                break;

            case EnumMonsterType.Beast:
                _name += beastNames[r.Next(beastNames.Count - 1)];
                break;

            case EnumMonsterType.Undead:
                _name += humanoidNames[r.Next(humanoidNames.Count - 1)];
                break;
            }
            return(_name);
        }
コード例 #7
0
 public void CheckEntryKillMonster(EnumMonsterType monsterType)
 {
 }
コード例 #8
0
ファイル: WorldGeneration.cs プロジェクト: Tonaplo/RPG
        /// <summary>
        /// This function generates a montername based on the type of the monster
        /// NOTE: Humanoids and undead share the same names.
        /// </summary>
        /// <param name="_npcType">The type of NPC being named</param>
        /// <returns>The new name of the NPC</returns>
        private static string GenerateMonterName(EnumMonsterType _npcType)
        {
            string _name = "";

            switch (_npcType)
            {
                case EnumMonsterType.Dragon:
                    _name += dragonNames[r.Next(dragonNames.Count - 1)];
                    break;
                case EnumMonsterType.Humanoid:
                    _name += humanoidNames[r.Next(humanoidNames.Count - 1)];
                    break;
                case EnumMonsterType.Beast:
                    _name += beastNames[r.Next(beastNames.Count - 1)];
                    break;
                case EnumMonsterType.Undead:
                    _name += humanoidNames[r.Next(humanoidNames.Count - 1)];
                    break;
            }
            return _name;
        }
コード例 #9
0
    private void OnGUI()
    {
        if (dataMap == null)
        {
            return;
        }
        EditorGUILayout.BeginHorizontal();
        //显示列表
        EditorGUILayout.BeginVertical(GUILayout.Width(300));
        if (GUILayout.Button("保存数据"))
        {
            string jsonStr = dataMap.Save();
            File.WriteAllText(dataFilePath, jsonStr, Encoding.UTF8);
            EditorUtility.DisplayDialog("保存数据", "保存成功!", "确认");
        }
        if (GUILayout.Button("新建跟节点"))
        {
            MapElement <EntryDataInfo> root = dataMap.FirstElement;
            MapElement <EntryDataInfo> node = dataMap.CreateMapElement();
            node.Deep  = 0;
            node.Value = new EntryDataInfo()
            {
                ID = node.ID, Name = "[None]"
            };
            root.CorrelativesNode.Add(node);
        }
        if (GUILayout.Button("新建子节点"))
        {
            if (selectTarget != null)
            {
                MapElement <EntryDataInfo> node = dataMap.CreateMapElement();
                node.Deep  = selectTarget.Deep + 1;
                node.Value = new EntryDataInfo()
                {
                    ID = node.ID, Name = "[None]"
                };
                selectTarget.CorrelativesNode.Add(node);
            }
            else
            {
                EditorUtility.DisplayDialog("建立子节点失败", "请先选择一个节点,若当前没有节点请建立一个根节点!", "确认");
            }
        }
        if (selectTarget != null && GUILayout.Button("删除选中节点") && EditorUtility.DisplayDialog("请再次确定!", "是否删除选中节点?", "确定删除", "取消"))
        {
            dataMap.Remove(selectTarget as MapElement <EntryDataInfo>);
            selectTarget = null;
        }
        GUILayout.Space(selectTarget != null ? 10 : 30);
        //使用递归在左侧构建树
        scrollPostion = EditorGUILayout.BeginScrollView(scrollPostion);
        {
            MapElement <EntryDataInfo>    root   = dataMap.FirstElement;
            IMapElement <EntryDataInfo>[] childs = root.Next(EnumMapTraversalModel.More);
            UpdateItemList(childs);
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        //显示选择的项
        EditorGUILayout.BeginVertical();
        if (selectTarget != null)
        {
            EditorGUILayout.LabelField("ID:" + selectTarget.ID);
            EditorGUILayout.LabelField("-----------------解锁条件-------------------");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("解锁条件");
            List <EntryDataInfo.EnumEntryUnlockType> entryUnlockTypeValues = entryUnlockTypeToExplanList.Select(temp => temp.Key).ToList();
            string[] entryUnlockTypeExplans = entryUnlockTypeToExplanList.Select(temp => temp.Value).ToArray();
            int      selectEntryUnlockIndex = entryUnlockTypeValues.IndexOf(selectEntryUnlockType);
            selectEntryUnlockIndex = EditorGUILayout.Popup(selectEntryUnlockIndex, entryUnlockTypeExplans);
            if (selectEntryUnlockIndex > 0)
            {
                selectEntryUnlockType = entryUnlockTypeValues[selectEntryUnlockIndex];
            }
            if (GUILayout.Button("添加") && !selectTarget.Value.UnlockDick.ContainsKey(selectEntryUnlockType))
            {
                selectTarget.Value.UnlockDick.Add(selectEntryUnlockType, 0);
            }
            EditorGUILayout.EndHorizontal();
            var entryUnlocks = selectTarget.Value.UnlockDick.Select(temp => temp.Key).ToArray();
            foreach (var entryUnlock in entryUnlocks)
            {
                GUILayout.Space(5);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("×", GUILayout.Width(20)) && EditorUtility.DisplayDialog("请再次确认!", "是否删除该解锁条件", "确认删除", "取消"))
                {
                    selectTarget.Value.UnlockDick.Remove(entryUnlock);
                    continue;
                }
                switch (entryUnlock)
                {
                case EntryDataInfo.EnumEntryUnlockType.OverTask:
                    EditorGUILayout.LabelField("解锁条件:完成任务!    任务ID:");
                    selectTarget.Value.UnlockDick[entryUnlock] = EditorGUILayout.IntField(selectTarget.Value.UnlockDick[entryUnlock]);
                    break;

                case EntryDataInfo.EnumEntryUnlockType.KillMonster:
                    EditorGUILayout.LabelField("解锁条件:杀死怪物!    怪物类型:");
                    EnumMonsterType monsterType = default(EnumMonsterType);
                    try
                    {
                        monsterType = (EnumMonsterType)Enum.Parse(typeof(EnumMonsterType), selectTarget.Value.UnlockDick[entryUnlock].ToString());
                    }
                    catch { }
                    List <EnumMonsterType> monsterTypeValues = monsterTypeToExplanList.Select(temp => temp.Key).ToList();
                    string[] monsterTypeExplans = monsterTypeToExplanList.Select(temp => temp.Value).ToArray();
                    int      monsterTypeIndex   = monsterTypeValues.IndexOf(monsterType);
                    monsterTypeIndex = EditorGUILayout.Popup(monsterTypeIndex, monsterTypeExplans);
                    if (monsterTypeIndex > 0)
                    {
                        monsterType = monsterTypeValues[monsterTypeIndex];
                    }
                    selectTarget.Value.UnlockDick[entryUnlock] = (int)monsterType;
                    break;

                case EntryDataInfo.EnumEntryUnlockType.ClickNPC:
                    EditorGUILayout.LabelField("解锁条件:点击NPC!    NPC ID :");
                    selectTarget.Value.UnlockDick[entryUnlock] = EditorGUILayout.IntField(selectTarget.Value.UnlockDick[entryUnlock]);
                    break;
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.LabelField("-----------------内容编辑-------------------");
            EditorGUILayout.BeginHorizontal();
            selectTarget.Value.Name = EditorGUILayout.TextField("要显示在列表中的内容", selectTarget.Value.Name);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("词条内容类型");
            List <EntryDataInfo.EnumEntryValueType> entryValueTypeValues = entryValueTypeToExplanList.Select(temp => temp.Key).ToList();
            string[] entryValueTypeExplans = entryValueTypeToExplanList.Select(temp => temp.Value).ToArray();
            int      selectEntryValueIndex = entryValueTypeValues.IndexOf(selectEntryValueType);
            selectEntryValueIndex = EditorGUILayout.Popup(selectEntryValueIndex, entryValueTypeExplans);
            if (selectEntryValueIndex >= 0)
            {
                selectEntryValueType = entryValueTypeValues[selectEntryValueIndex];
            }
            if (GUILayout.Button("添加"))
            {
                selectTarget.Value.Datas.Add(new EntryDataInfo.EntryValue()
                {
                    EntryValueType = selectEntryValueType, Data = ""
                });
            }
            EditorGUILayout.EndHorizontal();
            for (int i = 0; i < selectTarget.Value.Datas.Count; i++)
            {
                GUILayout.Space(15);
                EditorGUILayout.BeginHorizontal();
                int selectIndex = entryValueTypeValues.IndexOf(selectTarget.Value.Datas[i].EntryValueType);
                EditorGUILayout.LabelField("词条内容类型:" + entryValueTypeExplans[selectIndex], GUILayout.Width(120));
                if (GUILayout.Button("↑", GUILayout.Width(20)))
                {
                    if (i > 0)
                    {
                        EntryDataInfo.EntryValue entryValue = selectTarget.Value.Datas[i];
                        selectTarget.Value.Datas.Remove(entryValue);
                        selectTarget.Value.Datas.Insert(i - 1, entryValue);
                    }
                }
                if (GUILayout.Button("↓", GUILayout.Width(20)))
                {
                    if (i < selectTarget.Value.Datas.Count - 1)
                    {
                        EntryDataInfo.EntryValue entryValue = selectTarget.Value.Datas[i];
                        selectTarget.Value.Datas.Remove(entryValue);
                        if (i >= selectTarget.Value.Datas.Count - 1)
                        {
                            selectTarget.Value.Datas.Add(entryValue);
                        }
                        else
                        {
                            selectTarget.Value.Datas.Insert(i + 1, entryValue);
                        }
                    }
                }
                if (GUILayout.Button("×", GUILayout.Width(20)) && EditorUtility.DisplayDialog("请再次确定!", "是否删除该词条内容?", "确定删除", "取消"))
                {
                    selectTarget.Value.Datas.RemoveAt(i);
                    i--;
                    EditorGUILayout.EndHorizontal();
                    break;
                }
                EditorGUILayout.EndHorizontal();
                {
                    EntryDataInfo.EntryValue entryValue = selectTarget.Value.Datas[i];
                    switch (entryValue.EntryValueType)
                    {
                    case EntryDataInfo.EnumEntryValueType.Title:
                        entryValue.Data = EditorGUILayout.TextField(entryValue.Data);
                        break;

                    case EntryDataInfo.EnumEntryValueType.Text:
                        entryValue.Data = EditorGUILayout.TextArea(entryValue.Data, GUILayout.Height(100));
                        break;

                    case EntryDataInfo.EnumEntryValueType.Image:
                        Sprite sprite = SpriteManager.GetSrpite(entryValue.Data);
                        sprite          = (Sprite)EditorGUILayout.ObjectField(sprite, typeof(Sprite), true, GUILayout.Width(100), GUILayout.Height(100));
                        entryValue.Data = SpriteManager.GetName(sprite);
                        break;
                    }
                }
            }
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
コード例 #10
0
ファイル: PlayerQuest.cs プロジェクト: Tonaplo/RPG
        public override void UpdateQuest(Player _player, int _difficulty, NPC _enemy, int _healingDone, int _damageDone, double _charPercent, List<EnumCharClass> _class, bool battleWasWon)
        {
            if (monsterType == null)
            {
                monsterType = Function.PlayerQuestHandler.ReturnRandomMonsterType();

            }
            this.questText = "Defeat 3 " + monsterType + " of Normal difficulty";

            if (_difficulty == 0 && monsterType == _enemy.TypeOfNPC && battleWasWon)
            {
                this.currentValue++;
                if (currentValue == finalValue)
                    this.EndQuest(_player);
            }
        }
コード例 #11
0
ファイル: PlayerQuest.cs プロジェクト: Tonaplo/RPG
 public override void InitiateQuest(Player _player)
 {
     monsterType = Function.PlayerQuestHandler.ReturnRandomMonsterType();
     this.currentValue = 0;
     this.finalValue = 3;
     this.questText = "Defeat 3 " + monsterType + " of Normal difficulty";
 }
コード例 #12
0
        /// <summary>
        /// This method generates an NPC, along with a random AI
        /// </summary>
        /// <param name="_npcName">The name of the NPC - set to null for generated name</param>
        /// <param name="_npcLevel">The level the NPC should be</param>
        /// <param name="_npcType">The Monster Type of the NPC - set to null for generated type</param>
        /// <param name="_numberOfChars">The amount of targets, that the NPC should go for</param>
        /// <returns></returns>
        public static Core.Units.NPC GenerateNPC(string _npcName, int _npcLevel, int _difficulty, EnumMonsterType _npcType, int numberOfChars)
        {
            int realLevel = _npcLevel + _difficulty;
            int expGained = 0;
            int hp        = 0;

            if (realLevel <= 1)
            {
                hp = (int)(5 * numberOfChars * 1.2 * ((_npcLevel / 10) + 1));
            }
            else if (realLevel == 2)
            {
                hp = (int)((realLevel * 4) * numberOfChars * 1.2 + (realLevel / 10) * 2);
            }
            else
            {
                hp = (int)((realLevel * (realLevel - 1)) * numberOfChars * 1.2 + (_npcLevel / 10) * 2);
            }

            if (_difficulty == -4)
            {
                expGained = 0;
            }
            else if (_difficulty == -2)
            {
                expGained = (int)(realLevel * 0.5);
            }
            else if (_difficulty == 0)
            {
                expGained = realLevel;
            }
            else if (_difficulty == 2)
            {
                expGained = (int)(realLevel * 1.2);
            }
            else if (_difficulty == 4)
            {
                expGained = (int)(realLevel * 1.5);
            }

            expGained *= (int)(0.9 + (double)numberOfChars / 6.0);

            Core.Units.NPC returnedNPC = new Core.Units.NPC(_npcName, realLevel, hp, hp, _npcType, expGained, null, null);

            if (_npcType == EnumMonsterType.Null)
            {
                returnedNPC.TypeOfNPC = GenerateMonterType();
            }

            if (_npcName == null)
            {
                returnedNPC.UnitName = GenerateMonterName(returnedNPC.TypeOfNPC);
            }

            return(returnedNPC);
        }