コード例 #1
0
        private void CreateNewInstance(object m, CreateInstanceArgs e)
        {
            Manager.GetSingleton.InstanceManager.AddInstance(e.Instance);
            InstanceManager.SetupStructure(e.Instance);
            JarHelper.GetFile(e.Instance);

            _window.DialogResult = true;
            _window.Close();
        }
コード例 #2
0
        //一像素0.03
        public CellCollection(GameBoard gameBoard, GameObject prototype, int width, int height, int mine)
        {
            GameBoard = gameBoard;
            float   vectorCoefficient = 0.48f;
            Vector2 startPoint        = new Vector2(-width / 2, -height / 2) * vectorCoefficient;

            Width      = width;
            Height     = height;
            FloorLeft  = Width * Height - mine;
            CellMatrix = new Cell[Width, Height];
            Cells      = new List <Cell>();
            //地板
            for (int w = 0; w < Width; w++)
            {
                for (int h = 0; h < Height; h++)
                {
                    var cell = new Cell(w, h, gameBoard, prototype, startPoint + new Vector2(w, h) * vectorCoefficient, CellType.Floor, CellType.Floor);
                    CellMatrix[w, h] = (cell);
                    Cells.Add(cell);
                }
            }
            //埋雷
            var jar = JarHelper.GetJarOfIntPair(0, Width - 1, 0, Height - 1);

            for (int i = 0; i < mine; i++)
            {
                var vector = jar.Roll();
                var cell   = CellMatrix[vector.X, vector.Y];
                cell.SetBackgroundType(CellType.Mine);
                cell.IsMine = true;
                UpdateCellMatrixField(vector.X - 1, vector.Y - 1);
                UpdateCellMatrixField(vector.X - 1, vector.Y);
                UpdateCellMatrixField(vector.X - 1, vector.Y + 1);
                UpdateCellMatrixField(vector.X, vector.Y - 1);
                UpdateCellMatrixField(vector.X, vector.Y);
                UpdateCellMatrixField(vector.X, vector.Y + 1);
                UpdateCellMatrixField(vector.X + 1, vector.Y - 1);
                UpdateCellMatrixField(vector.X + 1, vector.Y);
                UpdateCellMatrixField(vector.X + 1, vector.Y + 1);
            }
            //预警
            for (int w = 0; w < Width; w++)
            {
                for (int h = 0; h < Height; h++)
                {
                    var cell = CellMatrix[w, h];
                    cell.SetBackgroundType(gameBoard.GetRiskyCellType(cell.IsMine, cell.RiskLevel));
                    Cells.Add(cell);
                }
            }
        }