示例#1
0
文件: Game.cs 项目: Rainy99/ITHero
        public int WorkNumber; //每天剩余的打工次数

        #endregion Fields

        #region Methods

        /// <summary>
        /// 初始化游戏数据
        /// </summary>
        public void Init()
        {
            Hero = new Player();
            Pack = new Parcel();
            this.TotalDays = 60;
            this.Days = this.TotalDays;
            this.StudyCount = 3;
            this.StudyNumber = this.StudyCount;
            this.WorkCount = 3;
            this.WorkNumber = this.WorkCount;
            this.PlayNumber = this.PlayCount;
            //初始化物品库
            AllGoodsList.Init();
            //初始化包裹(默认每种物品一个)
            Pack.GoodsList = new Dictionary<Goods, int>();
            Pack.GoodsList.Add(AllGoodsList.Bread, 1);
            Pack.GoodsList.Add(AllGoodsList.Calcium, 1);
            Pack.GoodsList.Add(AllGoodsList.Flower, 1);
            Pack.GoodsList.Add(AllGoodsList.Lottery, 1);
            Pack.GoodsList.Add(AllGoodsList.QQStar, 1);
            Pack.GoodsList.Add(AllGoodsList.Badge, 1);
            Pack.GoodsNumberList = new List<int>();
            for(int i = 0; i < Pack.GoodsList.Count; i++)
            {
                Pack.GoodsNumberList.Add(1);
            }
        }
示例#2
0
文件: Goods.cs 项目: Rainy99/ITHero
        /// <summary>
        /// 使用物品,返回使用结果字符串
        /// </summary>
        /// <param name="hero">使用者</param>
        /// <param name="goodsNumber">使用数量</param>
        public string Use(Player hero, int goodsNumber)
        {
            string str = "";	//提示信息
            if(GameManager.GameInfo.Pack.GoodsList[this] > 0)
            {
                //包裹中对应道具数量减1
                GameManager.GameInfo.Pack.GoodsList[this]--;
                //根据不同物品,增加使用者不同的属性值
                Random rand = new Random();
                int num = rand.Next(1, 10);		//使用物品时增加的属性值
                num = num * goodsNumber;		//乘以使用数量
                switch(this.type)
                {
                    case GoodsType.Prestige:
                        hero.Prestige += num;
                        str = "恭喜你增加了" + num + "点威望值,当前威望为" + hero.Prestige + "!";
                        break;
                    case GoodsType.Morality:
                        hero.Morality += num;
                        str = "恭喜你增加了" + num + "点道德值,当前道德为" + hero.Morality + "!";
                        break;
                    case GoodsType.Charm:
                        hero.Charm += num;
                        str = "恭喜你增加了" + num + "点魅力值,当前魅力为" + hero.Charm + "!";
                        break;
                    case GoodsType.Power:
                        hero.Power += num;
                        str = "恭喜你增加了" + num + "点力量值,当前力量为" + hero.Power + "!";
                        break;
                    case GoodsType.Luck:
                        hero.Luck += num;
                        str = "恭喜你增加了" + num + "点运气值,当前运气为" + hero.Luck + "!";
                        break;
                    case GoodsType.Intellect:
                        hero.Intellect += num;
                        str = "恭喜你增加了" + num + "点智力值,当前智力为" + hero.Intellect + "!";
                        break;
                }
            }
            else
            {
                str = "抱歉,你身上没有" + this.Name + "了!";
            }

            return str;
        }
示例#3
0
文件: Goods.cs 项目: Rainy99/ITHero
 /// <summary>
 /// 使用物品,返回使用结果字符串
 /// </summary>
 /// <param name="hero">使用者</param>
 public string Use(Player hero)
 {
     return this.Use(hero, 1);
 }