Exemple #1
0
        private void AIRound()
        {
            var viewScore = 0;

            for (int i = 1; i < myCards.Count; i++)
            {
                int number = (myCards[i] % 13) + 1;
                if (number > 10)
                {
                    number = 10;
                }
                viewScore += number;
            }

            if (hisScore < viewScore && hisScore < 21)
            {
                hisCards.Add(rs.NextNumber());
                Invalidate(new Rectangle(xoff, yoff, 324, 244));
                hisFull = false;
                myFull  = false;
            }
            else if (hisScore < viewScore + 6 && hisScore < 16)
            {
                hisCards.Add(rs.NextNumber());
                Invalidate(new Rectangle(xoff, yoff, 324, 244));
                hisFull = false;
                myFull  = false;
            }
            else
            {
                hisFull = true;
            }
            UpdateScore();
        }
Exemple #2
0
        private void NewRound()
        {
            myCards  = new List <int>();
            hisCards = new List <int>();
            rs       = new RandomSequence(52);

            for (int i = 0; i < 2; i++)
            {
                myCards.Add(rs.NextNumber());
                hisCards.Add(rs.NextNumber());
            }
            myFull  = false;
            hisFull = false;
            Invalidate(new Rectangle(xoff, yoff, 324, 244));
        }
Exemple #3
0
        private static void ReadBody(StreamReader sr, int mapWidth, int mapHeight, Random r,
                                     List <SceneManager.ScenePosData> cachedMapData, List <DbSceneSpecialPosData> cachedSpecialData,
                                     int wid, int height, int xoff, int yoff)
        {
            int cellWidth  = GameConstants.SceneTileStandardWidth * mapWidth / 1422;
            int cellHeight = GameConstants.SceneTileStandardHeight * mapHeight / 855;
            Dictionary <int, List <SceneManager.ScenePosData> > randomGroup = new Dictionary <int, List <SceneManager.ScenePosData> >();

            for (int i = 0; i < height; i++)
            {
                string[] data = sr.ReadLine().Split('\t');
                for (int j = 0; j < wid; j++)
                {
                    int val = Int32.Parse(data[j]);
                    if (val == 0)
                    {
                        continue;
                    }

                    int lineOff = (int)(cellWidth * (height - i - 1) * GameConstants.SceneTileGradient);
                    SceneManager.ScenePosData so = new SceneManager.ScenePosData
                    {
                        Id     = val,
                        X      = xoff + j * cellWidth + lineOff,
                        Y      = yoff + i * cellHeight,
                        Width  = cellWidth,
                        Height = cellHeight
                    };
                    if (val < 1000) //随机组
                    {
                        so.Id = (height - i) * 1000 + j + 1;
                        if (!randomGroup.ContainsKey(val))
                        {
                            randomGroup[val] = new List <SceneManager.ScenePosData>();
                        }
                        randomGroup[val].Add(so);
                    }
                    else
                    {
                        cachedMapData.Add(so);
                    }
                }
            }

            RandomSequence rs = new RandomSequence(randomGroup.Count, r);

            for (int i = 0; i < Math.Ceiling(randomGroup.Keys.Count * 0.5f); i++)
            {
                foreach (var randPos in randomGroup[rs.NextNumber() + 1])
                {
                    cachedMapData.Add(randPos);
                }
            }

            string line;

            while ((line = sr.ReadLine()) != null)
            {
                string[] data = line.Split('\t');
                if (data.Length < 2)
                {
                    continue;
                }

                var posData = new DbSceneSpecialPosData();
                posData.Id         = Int32.Parse(data[0]);
                posData.Type       = data[1];
                posData.MapSetting = true;
                if (data.Length > 2)
                {
                    posData.Info = Int32.Parse(data[2]);
                }
                cachedSpecialData.Add(posData);
            }
        }