Exemplo n.º 1
0
        public static int GainAll(List <Building> builds)
        {
            int count = 0;

            List <Building> gainAblebuilds = builds.FindAll(b => b.Gainable == true);

            Start(gainAblebuilds.Count);

            for (int i = 0; i < gainAblebuilds.Count; i++)
            {
                Building build = gainAblebuilds[i];

                if (BuildingManager.MoveBuilding(build, BowlPoint).Flag == ResultFlag.Success)
                {
                    //收割
                    if (Gain(build).Flag == ResultFlag.Success)
                    {
                        count++;
                    }
                    int j = 0;
                    for (; j < 10; j++)
                    {
                        if (BuildingManager.MoveBuilding(build, build.Location.Point).Flag == ResultFlag.Success)
                        {
                            break;
                        }
                    }
                    if (j == 10)
                    {
                        GainFailed("建筑物卡在聚宝盆内,无法移出");
                    }
                }
                GainComplelte(i + 1);
            }
            return(count);
        }
Exemplo n.º 2
0
        public static int AddExp(int exps, Point targetPoint, Item energeItem)
        {
            int count;
            int eachExp = 5;

            if (exps % eachExp == 0)
            {
                count = exps / eachExp;
            }
            else
            {
                count = exps / eachExp + 1;
            }

            Building build = new Building
            {
                BaseId   = 301,
                Location = new Rectangle
                {
                    Point  = targetPoint,
                    Width  = 4,
                    Length = 4
                }
            };
            int i = 0;

            for (; i < count; i++)
            {
                build.BaseId = 301;
                Result result = BuildingManager.Create(ref build);
                if (result.Flag == ResultFlag.EnergyNotEnough)
                {
                    Result energyResult = ItemManager.UseItem(energeItem);
                    if (energyResult.Flag == ResultFlag.Failed)
                    {
                        break;
                    }
                    else
                    {
                        i--; continue;
                    }
                }
                else if (result.Flag == ResultFlag.Failed)
                {
                    break;
                }

                Result desResult = null;

                for (int j = 0; j < 10; j++)
                {
                    desResult = BuildingManager.Destory(build);
                    if (desResult.Flag == ResultFlag.Success)
                    {
                        break;
                    }
                }

                if (desResult == null || desResult.Flag != ResultFlag.Success)
                {
                    break;
                }
            }

            return(i * eachExp);
        }