コード例 #1
0
ファイル: Controller.cs プロジェクト: Fr1tzler/Attribu
        public static void Update()
        {
            if (Model.HomeHP <= 0)
            {
                Program.currentState = 2;
                return;
            }
            if (MouseClicks.Count > 0)
            {
                var click = MouseClicks.Dequeue();
                if (Keyboard.IsKeyPressed(Keyboard.Key.N))
                {
                    var clickOnBoard = GetRectangleCoordinates(click);
                    if (MathModule.CorrectVector(clickOnBoard))
                    {
                        Model.AddTower(clickOnBoard);
                    }
                }
            }

            if (pressM == false)
            {
                if (Keyboard.IsKeyPressed(Keyboard.Key.M))
                {
                    pressM = true;
                    Model.NewWave(0);
                }
            }
            else if (!Keyboard.IsKeyPressed(Keyboard.Key.M))
            {
                pressM = false;
            }

            MousePosition           = (Vector2f)Mouse.GetPosition();
            NormalizedMousePosition = GetRectangleCoordinates(MousePosition);
        }
コード例 #2
0
        public int[,] ConstructMap(string[] src)
        {
            int
                                            x = src[0].Length,
                                            y = src.Length;
            var result = new int[x, y];

            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    if (src[j][i] != 'r')
                    {
                        result[i, j] = MathModule.RandInt(0, 3);
                        continue;
                    }

                    var up    = false;
                    var down  = false;
                    var left  = false;
                    var right = false;

                    if (0 < i)
                    {
                        if (src[j][i - 1] == 'r')
                        {
                            left = true;
                        }
                    }

                    if (i < x - 1)
                    {
                        if (src[j][i + 1] == 'r')
                        {
                            right = true;
                        }
                    }

                    if (0 < j)
                    {
                        if (src[j - 1][i] == 'r')
                        {
                            up = true;
                        }
                    }

                    if (j < y - 1)
                    {
                        if (src[j + 1][i] == 'r')
                        {
                            down = true;
                        }
                    }

                    if (up && down && !left && !right)
                    {
                        result[i, j] = 3;
                        continue;
                    }

                    if (!up && !down && left && right)
                    {
                        result[i, j] = 4;
                        continue;
                    }

                    if (up && !down && !left && right)
                    {
                        result[i, j] = 6;
                        continue;
                    }

                    if (!up && down && !left && right)
                    {
                        result[i, j] = 7;
                        continue;
                    }

                    if (!up && down && left && !right)
                    {
                        result[i, j] = 8;
                        continue;
                    }

                    if (up && !down && left && !right)
                    {
                        result[i, j] = 9;
                        continue;
                    }

                    result[i, j] = 5;
                }
            }

            return(result);
        } // хуита но робит и влом менять
コード例 #3
0
        } // хуита но робит и влом менять

        public void SetTile(int x, int y, int id)
        {
            tiles[x, y]          = new Tile(id);
            tiles[x, y].Position = MathModule.ViewTransform(x, y) + Config.PositionShift;
        }