コード例 #1
0
ファイル: Game.cs プロジェクト: ecsalunga/Cycle
        private void setRandomPlayer(int id)
        {
            int          x        = 0;
            LocationInfo location = null;

            while (x == 0)
            {
                x        = RND.Next(1, this.Config.X * this.Config.Y);
                location = this.GetLocation(x);
                if (location.PlayerId != this.Config.EmptyId)
                {
                    x = 0;
                }
            }

            location.Type       = LocationTypes.Base;
            location.Size       = SizeTypes.Medium;
            location.Army       = this.Config.PlayerArmy;
            location.Worker     = this.Config.PlayerWorker;
            location.PlayerId   = id;
            location.IsOccupied = true;
            this.Config.SetCycle(location);
            location.Current = RND.Next(0, location.Cycle);
            location.SetSize(this.Config.Height, this.Config.Width);
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: ecsalunga/Cycle
        private void generateLocations(ConfigInfo config)
        {
            this.Locations = new List <LocationInfo>();
            int count  = 1;
            int width  = this.Config.Width;
            int height = this.Config.Height;
            int large  = Convert.ToInt32(((width + height) / 2) * 0.1);
            int small  = Convert.ToInt32(((width + height) / 2) * -0.1);

            for (int y = 1; y <= config.Y; y++)
            {
                for (int x = 1; x <= config.X; x++)
                {
                    LocationInfo location = new LocationInfo(count, x, y);
                    location.PlayerId = config.EmptyId;
                    this.setRandomLocation(location);

                    int locationHeigth = height;
                    int locationWidth  = width;
                    if (location.Size == SizeTypes.Large)
                    {
                        locationHeigth += large;
                        locationWidth  += large;
                    }
                    else if (location.Size == SizeTypes.Small)
                    {
                        locationHeigth += small;
                        locationWidth  += small;
                    }

                    this.Config.SetCycle(location);
                    this.Config.SetArmy(location);
                    location.Army = RND.Next(1, location.Army * 2);
                    location.SetSize(locationHeigth, locationWidth);
                    this.Locations.Add(location);
                    count++;
                }
            }
        }