Example #1
0
        /// <summary>
        /// QRコード文字列を解析してフィールドへ変換します
        /// </summary>
        /// <param name="value">QRコード文字列</param>
        /// <returns>フィールド</returns>
        public static Game Parse(string value)
        {
            var spl = value.Split(' ', ':');

            int i = 0;
            int h = int.Parse(spl[i++]);
            int w = int.Parse(spl[i++]);

            var gen = new Generator(w, h);

            ICell[,] cells = new ICell[h, w];
            for (int y = 0; h > y; y++)
            {
                for (int x = 0; w > x; x++)
                {
                    cells[y, x] = new ScoreCell(int.Parse(spl[i++]));
                }
            }

            gen.Cells = cells;

            var field = new Field(gen);

            int y1 = int.Parse(spl[i++]);
            int x1 = int.Parse(spl[i++]);
            int y2 = int.Parse(spl[i++]);
            int x2 = int.Parse(spl[i++]);

            cells[--y1, --x1].SetState(Teams.Team1, CellState.Occupied);
            cells[--y2, --x2].SetState(Teams.Team1, CellState.Occupied);
            cells[y1, x2].SetState(Teams.Team2, CellState.Occupied);
            cells[y2, x1].SetState(Teams.Team2, CellState.Occupied);

            return(new Game(field, new Team(new Point(x1, y1), new Point(x2, y2)), new Team(new Point(x2, y1), new Point(x1, y2))));
        }
    public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
    {
        ScoreCell cell = tableView.GetReusableCell(_cellPrefab.reuseIdentifier) as ScoreCell;

        if (cell == null)
        {
            cell = (ScoreCell)GameObject.Instantiate(_cellPrefab);
        }
        Highscore data = _scores [row];

        cell.Name.text  = data.username;
        cell.Score.text = data.score.ToString();
        cell.Rank.text  = (row + 1).ToString();
        cell.Btn.name   = row.ToString();        // save index to button name
        return(cell);
    }
Example #3
0
    public void SetPlayerScore(PlayerData player, int roundNumber)
    {
        PlayerName.text = player.PlayerName;
        int cumulativeScore = 0;

        for (int i = 0; i < roundNumber; ++i)
        {
            GameObject newCellObj =
                GameObject.Instantiate(Resources.Load <GameObject>("Scoring/ScoreField"), transform);
            ScoreCell newCell     = newCellObj.GetComponent <ScoreCell>();
            int       roundNum    = i + 1;
            int       roundBid    = player.Bids[i];
            int       roundTricks = player.Tricks[i];
            int       points      = roundBid == roundTricks ? 10 + roundTricks : roundTricks;
            cumulativeScore += points;
            newCell.SetCellContents(roundNum, roundBid, roundTricks, points, cumulativeScore);
        }
    }
Example #4
0
        public ICell[,] Generate()
        {
            int halfw = (int)Math.Ceiling(Width / 2.0);
            int halfh = (int)Math.Ceiling(Height / 2.0);

            ICell[,] field = new ICell[halfh, halfw];

            //TODO ランダムがいい感じになるようにする
            for (int y = 0; halfh > y; y++)
            {
                for (int x = 0; halfw > x; x++)
                {
                    field[y, x] = new ScoreCell(Random.Next(1, Rule.MaximumCellScore + 1));
                }
            }

            //負の数を割り当てる
            int negCount = (int)(field.Length * NegativeRatio);

            (int, int)[] hist = new (int, int)[negCount];
Example #5
0
        private static ICell[,] DeserializeCells(BinaryReader br, int width, int height)
        {
            ICell[,] map = new ICell[height, width];
            for (int y = 0; height > y; y++)
            {
                for (int x = 0; width > x; x++)
                {
                    var score    = br.ReadInt32();
                    var text     = br.ReadString();
                    var priority = (CellPriority)br.ReadInt32();
                    var state1   = (CellState)br.ReadInt32();
                    var state2   = (CellState)br.ReadInt32();

                    map[y, x] = new ScoreCell(score)
                    {
                        Priority = priority,
                        State1   = state1,
                        State2   = state2,
                    };
                }
            }

            return(map);
        }