Ejemplo n.º 1
0
        public BoardResult MoveLeft()
        {
            var boardResult = EvaluateBoard(Board);

            Board = boardResult.Board;
            return(boardResult);
        }
Ejemplo n.º 2
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(this);
        }

        numOfEli = new int[5];

        //data structure of our game object
        map = new Element[areaSize, areaSize];

        //used to record element num in every column
        elementsCountInColumn = new int[9];

        //instantiate the seletors
        selector = (GameObject)Instantiate(selector, new Vector3(0f, 0f, 0f), Quaternion.identity);
        MoveSelector(new Vector3(-2, -2), false);

        for (int i = 0; i < elementsCountInColumn.Length; i++)
        {
            elementsCountInColumn[i] = 9;
        }

        LayoutElements();
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 生成地形
 /// </summary>
 /// <param name="elements"></param>
 /// <returns></returns>
 private Element[,] GenerateTerrain(Element[,] elements)
 {
     System.Random random = new System.Random();
     //elements.ForEach(x => x.Terrain = (Terrain)random.Next(0, 6));
     elements.ForEach(x => x.Terrain = Terrain.Dirt);
     return(elements);
 }
Ejemplo n.º 4
0
 public Map()
 {
     Elements = new Element[, ] {
         { Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall },
         { Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.SuperCoin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.SuperCoin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall },
         { Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall },
         { Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Ghost, Element.Ghost, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall },
         { Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.Coin, Element.EmptyField, Element.EmptyField, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Ghost, Element.Ghost, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.EmptyField, Element.EmptyField, Element.Coin, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField, Element.EmptyField },
         { Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall },
         { Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall },
         { Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.RightPacman, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.SuperCoin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.SuperCoin, Element.Wall },
         { Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall },
         { Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall },
         { Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Coin, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Coin, Element.Wall },
         { Element.Wall, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Coin, Element.Wall },
         { Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall, Element.Wall }
     };
 }
Ejemplo n.º 5
0
 public Collision(Element[,] mapElements)
 {
     this.mapElements = mapElements;
     int width = Data.GetWindowWidth();
     int height = Data.GetWindowHeight();
     this.render = new ConsoleRender(width, height);
 }
Ejemplo n.º 6
0
 public Field(int width, int height)
 {
     Width      = width;
     Height     = height;
     place      = new Element[width, height];
     Background = ResourceMain.blok;
 }
Ejemplo n.º 7
0
        public BoardResult MoveRight()
        {
            var boardResult = EvaluateBoard(Board.RotateClockwise().RotateClockwise())
                              .RotateCounterClockwise().RotateCounterClockwise();

            Board = boardResult.Board;
            return(boardResult);
        }
Ejemplo n.º 8
0
 private void initElements(int width, int height)
 {
     width    = width + 2;
     height   = height + 2;
     Elements = new Element[width, height];
     fillHorizontalBoundaryElements();
     fillVerticalBoundaryElements();
 }
Ejemplo n.º 9
0
        public DataMatrix(int width, int height, Element.ElementType type)
        {
            this.Width  = width;
            this.Height = height;
            matrixArray = new Element[width, height];

            InitializeMatrix(type);
        }
Ejemplo n.º 10
0
        BoardResult EvaluateBoard(Element[,] board)
        {
            var rowResults      = board.ToJagged().Select(EvaluateRow).ToArray();
            var resultingBoard  = rowResults.Select(x => x.Row).ToArray().ToMatrix();
            var movementResults = rowResults.Select(x => x.Movements).ToArray().ToMatrix();

            return(new BoardResult(resultingBoard, movementResults));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a board grid for a Crozzle.
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 public Board(int rows, int cols)
 {
     _BoardGrid       = new Element[rows + 1, cols + 1];
     _ActiveWordsList = new List <ActiveWord>();
     _Rows            = rows;
     _Cols            = cols;
     _GroupCount      = 0;
 }
Ejemplo n.º 12
0
    /// <summary>
    /// Check the field for matches of 3 or more and mark them for destruction
    /// </summary>
    public static Element[,] Check(Tile[,] field)
    {
        _toDestroy = new Element[GridController.Height, GridController.Width];

        FindHorizontal(field);
        FindVertical(field);

        return(_toDestroy);
    }
Ejemplo n.º 13
0
        public void UpdateVisibility()
        {
            Element[,] elementMap = Gameboard.Instance.GetMap();

            foreach (var element in elementMap)
            {
                UpdateVisibility(element);
            }
        }
Ejemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     timer    = timerStart;
     elements = GridControl.elements;
     if (mineCount != maxMineCount)
     {
         ModifyMineCount();
     }
 }
Ejemplo n.º 15
0
 public void Init(int x, int y)
 {
     XSize    = x;
     YSize    = y;
     tiles    = new GameObject[XSize, YSize];
     elements = new Element[XSize, YSize];
     SpawnGrid();
     Score          = 0;
     ScoreText.text = Score.ToString();
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 构造函数,传入一个二维数组,将内部矩阵设置为该二位数值,只是深度复制
 /// </summary>
 /// <param name="matrix"></param>
 public SimpleMatrix(Element[,] matrix) : this()
 {
     this.Matrix = new Element[matrix.GetLength(0), matrix.GetLength(1)];
     for (int row = 0; row < this.Row; row++)
     {
         for (int col = 0; col < this.Column; col++)
         {
             this.Matrix[row, col] = matrix[row, col];
         }
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 构造函数,传入矩阵的行,列数以及元素初始值
 /// </summary>
 /// <param name="rowSize">行数</param>
 /// <param name="colSize">列数</param>
 /// <param name="initValue">元素初始值</param>
 public SimpleMatrix(int rowSize, int colSize, Element initValue = 0)
 {
     this.Matrix = new Element[rowSize, colSize];
     for (int row = 0; row < rowSize; row++)
     {
         for (int col = 0; col < colSize; col++)
         {
             this.Matrix[row, col] = initValue;
         }
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 构造函数,矩阵行列数与初始值
 /// </summary>
 /// <param name="size">行列式大小</param>
 /// <param name="initValue">元素初始值</param>
 public Determinant(int size, Element initValue = 0)
 {
     this.Matrix = new Element[size, size];
     for (int row = 0; row < this.Size; row++)
     {
         for (int col = 0; col < this.Size; col++)
         {
             this.Matrix[row, col] = initValue;
         }
     }
 }
Ejemplo n.º 19
0
 public Face(Color color, int size = 3)
 {
     this.size = size;
     elements  = new Element[size, size];
     for (int i = 0; i < size; i++)
     {
         for (int j = 0; j < size; j++)
         {
             elements[i, j] = new Element(color);
         }
     }
 }
Ejemplo n.º 20
0
            public static bool FindCycle(int i0, int j0, Element[,] Shipment)
            {
                int count;

                count = (InitValueForSupplier.Length) * (InitValueForConsumer.Length);
                VerticesOfCycle.Clear();
                if (FindCycleHorizontally(i0, j0, count, Shipment))
                {
                    return(true);
                }
                return(false);
            }
Ejemplo n.º 21
0
 void StartGame()
 {
     StartCoroutine(timer());
     transform.position = Vector3.zero;
     SettingBtn.SetActive(true);
     btns.SetActive(false);
     ElementArray = new Element[WidthBlock, HeightBlock];
     xSize        = GetSpriteSize(CloneBlock.gameObject).x;
     ySize        = GetSpriteSize(CloneBlock.gameObject).y;
     transform.Translate(xSize * -0.5f * (WidthBlock - 1), ySize * -0.5f * (HeightBlock + 3), 0);
     GeneratorMineSweeper();
 }
Ejemplo n.º 22
0
        public void UpdateStorageCapacity()
        {
            SetDefault();
            Element[,] elementList = Gameboard.Instance.GetMap();

            foreach (var element in elementList)
            {
                if (element.HasElement && element.Level > 0)
                {
                    assingStorage(element);
                }
            }
        }
Ejemplo n.º 23
0
    void Start()
    {
        elements = new Element[width, height];

        if (GameManager.instance.Medals >= 5)
        {
            width          = 15;
            mineCount      = 35;
            levelText.text = "Advanced";
        }

        this.RemainingFlags = mineCount;
    }
Ejemplo n.º 24
0
    private static string[,] GetTagMap(Element[,] map)
    {
        string[,] tagMap = new string[map.GetLength(0), map.GetLength(1)];
        for (int x = 0; x < tagMap.GetLength(0); x++)
        {
            for (int y = 0; y < tagMap.GetLength(1); y++)
            {
                tagMap[x, y] = map[x, y].tag;
            }
        }

        return(tagMap);
    }
Ejemplo n.º 25
0
 public static void OutPut(Element[,] Shipment, int[] Supplier, int[] Consumer, bool WhithBasePoint = false)
 {
     if (WhithBasePoint)
     {
         for (int j = 0; j < Supplier.Length; j++)
         {
             Console.Write("    " + Supplier[j] + " ");
         }
         Console.WriteLine("\n");
         //выводим массив на экран
         for (int i = 0; i < Consumer.Length; i++)
         {
             Console.Write($"{Consumer[i], -4}");
             for (int j = 0; j < Supplier.Length; j++)
             {
                 //   Console.Write(Shipment[i, j].Delivery + $"({Shipment[i, j].Value})" + " ");
                 Console.Write($"{Shipment[i, j].Delivery, 2}({Shipment[i, j].Value, -2}) ");
             }
             Console.WriteLine();
         }
         ;
         Console.WriteLine("\n Таблица базисных точек");
         for (int i = 0; i < Consumer.Length; i++)
         {
             for (int j = 0; j < Supplier.Length; j++)
             {
                 Console.Write(Shipment[i, j].BasePoint + " ");
             }
             Console.WriteLine();
         }
     }
     else
     {
         for (int i = 0; i < Supplier.Length; i++)
         {
             Console.Write("    " + Supplier[i] + " ");
         }
         Console.WriteLine("\n");
         //выводим массив на экран
         for (int i = 0; i < Consumer.Length; i++)
         {
             Console.Write($"{Consumer[i],-4}");
             for (int j = 0; j < Supplier.Length; j++)
             {
                 Console.Write($"{Shipment[i, j].Delivery,2}({Shipment[i, j].Value,-2}) ");
             }
             Console.WriteLine();
         }
         ;
     }
 }
Ejemplo n.º 26
0
        private Element getRandomValid()
        {
            Element[,] map = _gameboard.GetMap();
            int frameCount = _gameboard.GetFrameCount;
            int x, y;

            do
            {
                x = Random.Next(0, frameCount);
                y = Random.Next(0, frameCount);
            } while (!map[x, y].IsValid || map[x, y].HasElement);

            return(map[x, y]);
        }
Ejemplo n.º 27
0
 public bool isWallTR(int x, int y, Element[,] c)
 {
     x = x + 1;
     y = y - 1;
     if ((((x < 0) || (y < 0)) || (x > c.GetLength(0) - 1) || (y > c.GetLength(1) - 1)) || c[x, y] == null || c[x, y].et.Equals(Enum.ElementTypes.PacDot) || c[x, y].et.Equals(Enum.ElementTypes.PacPlayer) || c[x, y].et.Equals(Enum.ElementTypes.Ghost) || c[x, y].et.Equals(Enum.ElementTypes.Powerup) || c[x, y].et.Equals(Enum.ElementTypes.Fruit) || c[x, y].et.Equals(Enum.ElementTypes.GhostSpawn))
     {
         return(false);
     }
     else if (c[x, y].et.Equals(Enum.ElementTypes.Wall))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 28
0
        public static void GetString(Element[,] matrix)
        {
            StringBuilder matrixString = new StringBuilder();

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    matrixString.Append($"{matrix[row, col]} ");
                }
                matrixString.Append("\n");
            }
            Console.WriteLine(matrixString.ToString());
        }
Ejemplo n.º 29
0
 private static void _matrixRateInitialize(Element[,] matrix)
 {
     for (var rowNumber = 0; rowNumber < matrix.GetLength(0); rowNumber++)
     {
         for (var columnNumber = 0; columnNumber < matrix.GetLength(1); columnNumber++)
         {
             matrix[rowNumber, columnNumber] = new Element
             {
                 Value = InputAndOutput.
                         GetNumberFromUser($"Enter rate of [{rowNumber}, {columnNumber}] : ")
             };
         }
     }
 }
Ejemplo n.º 30
0
            public static void FindNewBasePoint(int[] supplier, int[] Consumer, Element[,] Shipment)
            {
                int  i, j;
                bool ok     = false;
                bool IsTrue = true;

                for (i = 0; i < Consumer.Length; i++)
                {
                    for (j = 0; j < supplier.Length; j++)
                    {
                        if (Shipment[i, j].BasePoint == 0)
                        {
                            ok = true;
                            break;
                        }
                    }
                    if (ok)
                    {
                        break;
                    }
                }
                if (!ok)
                {
                    Console.WriteLine("ОШИБКА! НУЖНЫХ ТОЧЕК НЕТУ");
                }



                while (IsTrue)
                {
                    Random randForI = new Random();
                    Random randForJ = new Random();
                    i = randForI.Next(0, Consumer.Length);
                    j = randForJ.Next(0, supplier.Length);
                    if (Shipment[i, j].BasePoint == 1)
                    {
                        continue;
                    }
                    if (Shipment[i, j].Delivery != 0)
                    {
                        Console.WriteLine("ОЧень странно, базовая точка не нулевой быть не может");
                    }
                    //if (FindCycle(i, j, Shipment))
                    //    continue;
                    Shipment[i, j].BasePoint = 1;
                    Console.WriteLine("В базис введена ячейка: [" + i + ", " + j + "].");
                    IsTrue = false;
                }
            }
Ejemplo n.º 31
0
 public Game(Element[,] map, Hero hero, int treasures, int score = 0, int health = 3)
 {
     Health    = health;
     Score     = score;
     Treasures = treasures;
     Hero      = new Hero(hero.X, hero.Y);
     Map       = new Element[map.GetLength(0), map.GetLength(1)];
     for (int i = 0; i < map.GetLength(0); i++)
     {
         for (int j = 0; j < map.GetLength(1); j++)
         {
             Map[i, j] = (Element)map[i, j].Clone();
         }
     }
 }
Ejemplo n.º 32
0
        public static Element[,] CreateLevel()
        {
            Initialisation();

            elements = new Element[rowsByDimention, colsByDimention];

            // insert eagle
            eagleRowLevelCordinate = rowsByDimention - 1;
            eagleColLevelCordinate = (colsByDimention - 1) / 2;
            int eagleRow = eagleRowLevelCordinate * changeDistance + minRow;
            int eagleCol = eagleColLevelCordinate * changeDistance;

            Element eagle = new Element(ElementType.Eagle, eagleRow, eagleCol);
            elements[eagleRowLevelCordinate, eagleColLevelCordinate] = eagle;
            render.DrawElement(eagle);

            return Create();
        }
Ejemplo n.º 33
0
        public GameEngine(uint levelNumber)
        {
            int width = Data.GetWindowWidth();
            int height = Data.GetWindowHeight();
            this.render = new ConsoleRender(width, height);

            this.level = Data.GetLevel(levelNumber);
            havePlayerFire = false;
            isExit = false;
            this.enemys = new List<Tank>();
            FillStartEnemyPositions();
            createEnemyCallCount = 0;
            rand = new Random();
            this.playerMisals = new List<Fire>();
            this.enemyMisals = new List<Fire>();
            this.collision = new Collision(level);
            this.enemyOnLevel = 20;
            this.isEscapePressed = false;
            this.enemyPlayCount = 0;
            this.enemyNumber = 0;
        }
Ejemplo n.º 34
0
        /*
         * Constructeur prive pour empecher l'acces au constructeur par
         * une autre classe.
        */
        private Gameboard()
        {
            _frameWidth = (Width - StartWidth) / FrameCount;
            _frameHeight = (Height - StartHeight) / FrameCount;

            // Initialisation de toutes les cases du jeu
            _map = new Element[FrameCount, FrameCount];
            for (int i = 0; i < FrameCount; i++)
            {
                for (int j = 0; j < FrameCount; j++)
                {
                    _map[i, j] = new Element
                    {
                        PositionX = i,
                        PositionY = j
                    };

                    //set x and Y
                    Rectangle elementRect = _map[i, j].GetElement();

                    // Position for building element
                    elementRect.Margin = new Thickness(i*_frameWidth + StartWidth, j*_frameHeight + (StartHeight-_frameHeight), 0, 0);

                    // Position for building level
                    Rectangle levelRect = _map[i, j].GetLevelElement();
                    levelRect.Margin = new Thickness(elementRect.Margin.Left + _frameWidth / 3, elementRect.Margin.Top + _frameHeight, 0, 0);

                    // Position for label level
                    double left = levelRect.Margin.Left;
                    double top = levelRect.Margin.Top;
                    _map[i, j].GetLevelLabel().Margin = new Thickness(left-3.1, top-7, 0, 0);

                    // Position for select element
                    Border selectRect = _map[i, j].GetSelectElement();
                    selectRect.Margin = new Thickness(i * _frameWidth + StartWidth, j * _frameHeight + (StartHeight - _frameHeight)+5, 0, 0);
                }
            }
        }
Ejemplo n.º 35
0
        public bool Create(string filename_)
        {
            Inputfile = filename_;
            if (LoadFromFile() != 0)
                return false;

            SetParameters();
            count = 0;

            elements = new Element[imax, jmax];
            int i, j;

            for (i = 0; i < imax; i++)
                for (j = 0; j < jmax; j++)
                {
                    Element elem = new Element();
                    elem.id = i*j+j;
                    elem.u = 0;
                    elem.cfdist = dh;
                    elements[i,j] = elem;
                }

            SetBoundary();
            return true;
        }
Ejemplo n.º 36
0
 //constructor
 public Matrix(int Cols, int Rows)
 {
     ColsCount = Cols;
     RowsCount = Rows;
     elements = new Element[Cols, Rows];
 }
Ejemplo n.º 37
0
 private void NewGame()
 {
     ClearForm();
     GameOver = false;
     StartPos = new Point(20, 50);
     Point Loc = new Point(StartPos.X, StartPos.Y);
     PButtons = new Button[Width * Height];
     Pole = new Element[Height, Width];
     for (int i = 0; i < Height; i++)
     {
         for (int j = 0; j < Width; j++)
         {
             Pole[i, j] = new Element();
             PButtons[i * Width + j] = new Button();
             PButtons[i * Width + j].Text = "";
             PButtons[i * Width + j].Location = new Point(Loc.X, Loc.Y);
             PButtons[i * Width + j].Size = new Size(_Size, _Size);
             PButtons[i * Width + j].BackColor = Color.FromArgb(255, 255, 255);
             PButtons[i * Width + j].MouseDown += new MouseEventHandler(btnMouseClick);
             Loc.X += _Size;
             this.Controls.Add(PButtons[i * Width + j]);
         }
         Loc.Y += _Size;
         Loc.X = StartPos.X;
     }
     GeneratePole();
 }