当前位置: 首页>>代码示例>>C#>>正文


C# Skill.CopyFrom方法代码示例

本文整理汇总了C#中Skill.CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Skill.CopyFrom方法的具体用法?C# Skill.CopyFrom怎么用?C# Skill.CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Skill的用法示例。


在下文中一共展示了Skill.CopyFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadPlayer

        public bool ReadPlayer(string playerName, out Player player)
        {
            player = null;

            string fileName = GetSaveFileName(playerName);
            if (!System.IO.File.Exists(fileName)) return false;

            using (StreamReader sr = new StreamReader(fileName))
            {
                string strLine = "";

                while (!sr.EndOfStream)
                {
                    strLine = sr.ReadLine();

                    // uid,name,level,exp,a,d,p,k
                    string[] datas = null;
                    Hero hero = null;
                    {
                        datas = strLine.Split(new char[] { ',' });

                        player = new Player();
                        player._id = System.Convert.ToInt32(datas[0]);
                        player._name = datas[1];

                        hero = new Hero();
                        hero._id = player._id;
                        hero._name = player._name;
                        hero._level = System.Convert.ToInt32(datas[2]);
                        hero._experience = System.Convert.ToInt32(datas[3]);
                        hero._attack = System.Convert.ToInt32(datas[4]);
                        hero._defense = System.Convert.ToInt32(datas[5]);
                        hero._power = System.Convert.ToInt32(datas[6]);
                        hero._knowledge = System.Convert.ToInt32(datas[7]);
                    }

                    // skillId,skillLevel,...
                    {
                        datas = strLine.Split(new char[] { ',' });

                        for (int i = 0; i < datas.Length; i += 2)
                        {
                            int skillId = System.Convert.ToInt32(datas[i]);
                            int skillLevel = System.Convert.ToInt32(datas[i + 1]);

                            Skill skill = new Skill();
                            skill.CopyFrom((Skill)Heroes.Core.Setting._skills[skillId]);
                            skill._level = skillLevel;

                            hero._skills.Add(skill._id, skill);
                        }
                    }

                    // spells
                    {
                        datas = strLine.Split(new char[] { ',' });

                        for (int i = 0; i < datas.Length; i++)
                        {
                            int spellId = System.Convert.ToInt32(datas[i]);

                            Spell spell = new Spell();
                            spell.CopyFrom((Spell)Heroes.Core.Setting._spells[spellId]);

                            hero._spells.Add(spell._id, spell);
                        }
                    }

                    // artifacts
                }
            }

            return true;
        }
开发者ID:sakseichek,项目名称:homm,代码行数:74,代码来源:Game.cs

示例2: GetRandomSkills

        private void GetRandomSkills(Hashtable idLevels, ArrayList lst, int slots)
        {
            // random
            Random rnd = new Random();
            Hashtable skills = new Hashtable();
            while (skills.Count < slots)
            {
                int index = rnd.Next(0, lst.Count);
                int id2 = (int)lst[index];
                if (skills.ContainsKey(id2)) continue;
                skills.Add(id2, id2);

                Skill skill = new Skill();
                skill.CopyFrom((Skill)Heroes.Core.Setting._skills[id2]);
                skill._level = (int)idLevels[id2];
                _skills.Add(skill);
            }
        }
开发者ID:sakseichek,项目名称:homm,代码行数:18,代码来源:frmLevelUp.cs


注:本文中的Skill.CopyFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。