protected override void Dispose(bool disposing)
            {
                _owner               = null;
                _lineGraphic         = null;
                _sliceControlGraphic = null;
                _stateControlGraphic = null;

                base.Dispose(disposing);
            }
Ejemplo n.º 2
0
			protected override void Dispose(bool disposing)
			{
				_owner = null;
				_lineGraphic = null;
				_sliceControlGraphic = null;
				_stateControlGraphic = null;

				base.Dispose(disposing);
			}
Ejemplo n.º 3
0
			public ResliceToolGraphic(ResliceTool owner)
			{
				LineGraphic lineGraphic = new LineGraphic();
				MprMoveControlGraphic moveControlGraphic = new MprMoveControlGraphic(lineGraphic);
				moveControlGraphic.UndoableOperationStart += OnControlGraphicUndoableOperationStart;
				moveControlGraphic.UndoableOperationStop += OnControlGraphicUndoableOperationStop;
				moveControlGraphic.UndoableOperationCancel += OnControlGraphicUndoableOperationCancel;
				MprLineStretchControlGraphic lineControlGraphic = new MprLineStretchControlGraphic(moveControlGraphic);
				lineControlGraphic.UndoableOperationStart += OnControlGraphicUndoableOperationStart;
				lineControlGraphic.UndoableOperationStop += OnControlGraphicUndoableOperationStop;
				lineControlGraphic.UndoableOperationCancel += OnControlGraphicUndoableOperationCancel;
				SliceControlGraphic sliceControlGraphic = new SliceControlGraphic(lineControlGraphic, this);
				StandardStatefulGraphic statefulGraphic = new StandardStatefulGraphic(sliceControlGraphic);
				statefulGraphic.State = statefulGraphic.CreateInactiveState();
				base.Graphics.Add(statefulGraphic);

				_stateControlGraphic = statefulGraphic;
				_sliceControlGraphic = sliceControlGraphic;
				_lineGraphic = lineGraphic;
				_owner = owner;
			}
        protected void AddText(LineGraphic graphic, string text, float position = 0.5f)
        {
            var labelBox = new Omnigraffle.ShapedGraphic(NextId, Omnigraffle.Shape.Rectangle, 50, 50, 100, 100);

            labelBox.Text = new Omnigraffle.TextInfo(text)
            {
                Alignement = KAOSTools.OmnigraffleExport.Omnigraffle.TextAlignement.Center,
                SideMargin = 0, TopBottomMargin = 0
            };
            labelBox.FontInfo.Size      = 8;
            labelBox.Style.Shadow.Draws = false;
            labelBox.FitText            = KAOSTools.OmnigraffleExport.Omnigraffle.FitText.Yes;
            // labelBox.Wrap = false;
            labelBox.Flow               = KAOSTools.OmnigraffleExport.Omnigraffle.Flow.Resize;
            labelBox.Style.Fill.Color   = new KAOSTools.OmnigraffleExport.Omnigraffle.Color(1, 1, 1);
            labelBox.Style.Stroke.Draws = false;
            labelBox.Line               = new LineInfo(graphic.ID)
            {
                Position = position
            };

            sheet.GraphicsList.Add(labelBox);
        }
            public ResliceToolGraphic(ResliceTool owner)
            {
                LineGraphic           lineGraphic        = new LineGraphic();
                MprMoveControlGraphic moveControlGraphic = new MprMoveControlGraphic(lineGraphic);

                moveControlGraphic.UndoableOperationStart  += OnControlGraphicUndoableOperationStart;
                moveControlGraphic.UndoableOperationStop   += OnControlGraphicUndoableOperationStop;
                moveControlGraphic.UndoableOperationCancel += OnControlGraphicUndoableOperationCancel;
                MprLineStretchControlGraphic lineControlGraphic = new MprLineStretchControlGraphic(moveControlGraphic);

                lineControlGraphic.UndoableOperationStart  += OnControlGraphicUndoableOperationStart;
                lineControlGraphic.UndoableOperationStop   += OnControlGraphicUndoableOperationStop;
                lineControlGraphic.UndoableOperationCancel += OnControlGraphicUndoableOperationCancel;
                SliceControlGraphic     sliceControlGraphic = new SliceControlGraphic(lineControlGraphic, this);
                StandardStatefulGraphic statefulGraphic     = new StandardStatefulGraphic(sliceControlGraphic);

                statefulGraphic.State = statefulGraphic.CreateInactiveState();
                base.Graphics.Add(statefulGraphic);

                _stateControlGraphic = statefulGraphic;
                _sliceControlGraphic = sliceControlGraphic;
                _lineGraphic         = lineGraphic;
                _owner = owner;
            }
Ejemplo n.º 6
0
        public void DrawGame()
        {
            var baseMatrixWithLaserShake = Matrix.CreateTranslation(
                new Vector3(gameController.laserPlayer.laserShake.CurrentShake, 0))
                                           * baseMatrix;

            var mousePos = InputController.CurrentMousePosition;

            graphicsDevice.Clear(Color.Black);

            for (int i = coinBackgroundLayers.Count - 1; i >= 0; i--)
            {
                var coinBackground = coinBackgroundLayers[i];

                var drawColour = new Color(
                    coinBackground.currentAlpha,
                    coinBackground.currentAlpha,
                    coinBackground.currentAlpha, 1f);

                // Create matrix for coin backgrounds.
                Matrix coinBackgroundMatrix =
                    Matrix.CreateTranslation(-ChangeGame.WINDOW_WIDTH / 2, -ChangeGame.PLAYABLE_AREA_HEIGHT, 0)
                    * baseMatrix
                    * Matrix.CreateScale(coinBackground.currentScale)
                    * Matrix.CreateTranslation(
                        ChangeGame.PLAYABLE_AREA_WIDTH * ChangeGame.SCALE / 2,
                        ChangeGame.PLAYABLE_AREA_HEIGHT * ChangeGame.SCALE - coinBackground.currentTranslate,
                        0);

                // Draw buffer coin background.
                batch.Begin(
                    sortMode: SpriteSortMode.BackToFront,
                    samplerState: samplerState,
                    transformMatrix: coinBackgroundMatrix);
                {
                    batch.Draw(coinBackground.graphic, new Vector2(0, 0), drawColour);
                    batch.Draw(VaultWalls, new Vector2(-vaultWallWidth, 0), drawColour);
                    batch.Draw(VaultWalls, new Vector2(ChangeGame.PLAYABLE_AREA_WIDTH, 0), drawColour);
                    batch.Draw(VaultFloor, new Vector2(-vaultWallWidth, -vaultFloorHeight), drawColour);
                    batch.Draw(VaultFloor, new Vector2(-vaultWallWidth, ChangeGame.PLAYABLE_AREA_HEIGHT), drawColour);
                }
                batch.End();
            }

            // Draw current coin background.
            batch.Begin(samplerState: samplerState, transformMatrix: baseMatrix);
            {
                batch.Draw(currentCoinBackground, new Vector2(0, 0), Color.White);
            }
            batch.End();

            // Draw falling coins.
            batch.Begin(samplerState: samplerState, transformMatrix: baseMatrix);
            {
                foreach (var coin in gameController.FallingCoins)
                {
                    batch.Draw(coinGraphic, coin.CollisionRect.Location.ToVector2(), Color.White);
                }
            }
            batch.End();

            // Draw paddle background.
            batch.Begin(samplerState: samplerState, transformMatrix: baseScaleMatrix);
            {
                batch.Draw(paddleBackground, new Vector2(0, ChangeGame.WINDOW_HEIGHT - ChangeGame.PADDLE_AREA_HEIGHT), Color.White);
            }
            batch.End();

            // Draw enemies.
            batch.Begin(samplerState: samplerState, transformMatrix: baseMatrix);
            {
                foreach (var c in gameController.corpses)
                {
                    var oldEnemySize = new Vector2(10, 10);
                    var enemyDiff    = new Vector2(piggyBankGraphic.Width, piggyBankGraphic.Height) - oldEnemySize;

                    bool isBackwardsVacuum = c.EnemyReference is VacuumEnemy && c.EnemyReference.Direction < 0;

                    var fireOffset = new Vector2(-1, -5);
                    if (isBackwardsVacuum)
                    {
                        fireOffset += new Vector2(5, 0);
                    }

                    var effect    = c.speed.X < 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
                    var effectInv = c.speed.X > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

                    batch.Draw(enemyFireGraphics[c.animationFrame % enemyFireGraphics.Length],
                               (c.Position + fireOffset).ToPoint().ToVector2(),
                               null,
                               Color.White,
                               0, Vector2.Zero, 1, effect, 0);

                    DrawEnemy(batch, c.EnemyReference, c.Position.ToPoint().ToVector2());
                }
                for (int i = 0; i < gameController.enemies.Count; i++)
                {
                    DrawEnemy(batch, gameController.enemies[i], gameController.enemies[i].CollisionRect.Location.ToVector2());
                }
            }
            batch.End();

            // Draw back of paddle.
            if (gameController.CurrentStage.HasFlag(Stage.StageFlags.PaddlePlayerEnabled))
            {
                batch.Begin(samplerState: samplerState, transformMatrix: baseMatrix);
                {
                    batch.Draw(paddleGraphicBack, gameController.paddlePlayer.CollisionRect.Location.ToVector2(), Color.White);
                }
                batch.End();
            }

            // Draw money.
            batch.Begin(samplerState: samplerState, transformMatrix: baseMatrix);
            {
                foreach (var c in gameController.notesOnFire)
                {
                    var fireOffset = new Vector2(-1, -(NoteOnFire.HEIGHT - Note.HEIGHT));

                    var effect = c.IsFlipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

                    var noteFireGraphicsSet = noteFireGraphics[c.Type];
                    batch.Draw(noteFireGraphicsSet[c.animationFrame % noteFireGraphicsSet.Length],
                               (c.Position + fireOffset).ToPoint().ToVector2(),
                               null,
                               Color.White,
                               0, Vector2.Zero, 1, effect, 0);
                }
                foreach (var note in gameController.notes)
                {
                    if (!note.InsideVacuum)
                    {
                        batch.Draw(noteGraphics[note.Type], note.CollisionRect.Location.ToVector2(), Color.White);
                    }
                }
            }
            batch.End();

            // Draw front of paddle.
            if (gameController.CurrentStage.HasFlag(Stage.StageFlags.PaddlePlayerEnabled))
            {
                batch.Begin(samplerState: samplerState, transformMatrix: baseMatrix);
                {
                    batch.Draw(paddleGraphicFront, gameController.paddlePlayer.CollisionRect.Location.ToVector2(), Color.White);
                }
                batch.End();
            }

            var scoreLength    = ScoreRenderer.LengthOf(gameController.currentCoinScore / 100d);
            var totalArea      = ChangeGame.PLAYABLE_AREA_WIDTH - scoreLength;
            var totalAreaRatio = (ChangeGame.PLAYABLE_AREA_WIDTH - scoreLength) / (float)ChangeGame.PLAYABLE_AREA_WIDTH;

            #region Draw hud
            // Calculate values for drawing the hud.
            var laserPercentage = (int)(gameController.laserPlayer.laserCharge * totalArea) / (float)totalArea * totalAreaRatio;

            var healthPercentage = (gameController.CurrentStage.MaxNotesMissed - gameController.notesMissed) / (float)gameController.CurrentStage.MaxNotesMissed;
            healthPercentage = (int)(healthPercentage * totalArea) / (float)totalArea * totalAreaRatio;

            var totalDuration   = gameController.CurrentStage.RequiredTimePassed.TotalSeconds;
            var currentDuration = gameController.CurrentStage.timePassed.TotalSeconds;

            float progressPercentage;

            if (gameController.CurrentStage.HasFlag(Stage.StageFlags.CompleteOnTimePassed))
            {
                progressPercentage = (float)(currentDuration / totalDuration);
            }
            else if (gameController.CurrentStage.HasFlag(Stage.StageFlags.CompleteOnCollectCoins))
            {
                progressPercentage = gameController.CurrentStage.coinsCollected / (float)gameController.CurrentStage.RequiredCoins;
            }
            else
            {
                progressPercentage = 1f;
            }

            progressPercentage = (int)(progressPercentage * totalArea) / (float)totalArea * totalAreaRatio;

            // Draw the hud.
            batch.Begin(samplerState: samplerState, transformMatrix: baseScaleMatrix);
            {
                batch.Draw(hudBackground, Vector2.Zero, Color.White);

                batch.Draw(hudLaserCharge,
                           new Vector2(scoreLength, 3),
                           null,
                           Color.White,
                           0, Vector2.Zero,
                           new Vector2(laserPercentage, 1),
                           SpriteEffects.None, 0);

                batch.Draw(hudPlayerHealth,
                           new Vector2(scoreLength, 1),
                           null,
                           Color.White,
                           0, Vector2.Zero,
                           new Vector2(healthPercentage, 1),
                           SpriteEffects.None, 0);

                batch.Draw(hudTimeRemaining,
                           new Vector2(scoreLength, 0),
                           null,
                           Color.White,
                           0, Vector2.Zero,
                           new Vector2(progressPercentage, 1),
                           SpriteEffects.None, 0);

                batch.Draw(scoreBackground, Vector2.Zero, Color.White);
                DrawScore(batch, Vector2.Zero, gameController.currentCoinScore / 100d);
            }
            batch.End();
            #endregion

            // Draw laser player (over HUD).
            if (gameController.CurrentStage.HasFlag(Stage.StageFlags.LaserPlayerEnabled))
            {
                batch.Begin(samplerState: samplerState, transformMatrix: baseMatrixWithLaserShake);
                {
                    batch.Draw(playerGraphic, (gameController.laserPlayer.CollisionRect.Location + laserPlayerOffset).ToVector2(), Color.White);
                }
                batch.End();
            }

            // Draw lasers.
            if (gameController.laserPlayer.FiringLaser)
            {
                Color[] laserData = Enumerable.Repeat(Color.Transparent,
                                                      ChangeGame.PLAYABLE_AREA_WIDTH * ChangeGame.PLAYABLE_AREA_HEIGHT).ToArray();

                // Add both lasers to colour data.
                LineGraphic.CreateLineBoundsCheck(laserData,
                                                  gameController.laserPlayer.LeftEyePos.X, gameController.laserPlayer.LeftEyePos.Y,
                                                  mousePos.X, mousePos.Y, Color.Red);
                LineGraphic.CreateLineBoundsCheck(laserData,
                                                  gameController.laserPlayer.RightEyePos.X, gameController.laserPlayer.RightEyePos.Y,
                                                  mousePos.X, mousePos.Y, Color.Red);

                playerLasersLayer.SetData(laserData);

                batch.Begin(samplerState: samplerState, transformMatrix: baseMatrixWithLaserShake, blendState: BlendState.NonPremultiplied);
                {
                    var   laserAlpha     = Math.Min(gameController.laserPlayer.laserCharge * 8, 1f);
                    Color laserFadeColor = new Color(1f, 1f, 1f, laserAlpha);

                    batch.Draw(playerLasersLayer, Vector2.Zero, laserFadeColor);
                }
                batch.End();
            }

            // If there is a Stage Complete menu, draw it.
            if (gameController.CurrentMenu != null && gameController.CurrentMenu is StageCompleteMenu)
            {
                batch.Begin(samplerState: samplerState, transformMatrix: baseScaleMatrix);
                {
                    batch.Draw(stageOverBackground, gameController.CurrentMenu.MenuOffset.ToPoint().ToVector2() + stageCompleteOffset.ToVector2(), Color.White);
                }
                batch.End();
            }

            // Clean up temporary enemy Texture2Ds.
            foreach (var t in temporaryVacuumTextureStore)
            {
                t.Dispose();
            }
            temporaryVacuumTextureStore.Clear();
        }
Ejemplo n.º 7
0
    /// <summary>
    /// Comienza el juego al darle al botón
    /// </summary>
    public void Play()
    {
        playerSelectionPanel.SetActive(false);

        realRows    = rows * 2 + 1;
        realColumns = columns * 2 + 1;

        int count = 0;

        Vector3 pos = this.transform.position;

        int s_rows    = 0,
            s_columns = 0;

        // Se inicializa el tablero
        board = new Board(rows, columns, players.ToArray());
        board.InitializePlayerText(this.activePlayerText);

        board.boardElements = new GameObject[realRows, realColumns];

        CreateBoard();
        board.lines = new Line[rows * 2 + 1, columns + 1];

        // Instancias de círculos y líneas
        for (int row = 0; row < realRows; row++)
        {
            for (int column = 0; column < realColumns; column++)
            {
                if ((row + 1) % 2 != 0)
                {
                    if ((column + 1) % 2 != 0)
                    {
                        GameObject obj = Instantiate(circle, pos, this.transform.rotation, this.transform);
                        obj.GetComponent <Image>().sprite = circleSprites[UnityEngine.Random.Range(0, 5)];
                        board.boardElements[row, column]  = obj;
                        obj.transform.SetParent(circles_container.transform, true);
                    }
                    if ((column + 1) % 2 == 0)
                    {
                        GameObject obj = Instantiate(line, pos, this.transform.rotation, this.transform);
                        obj.name = "Line " + ++count;
                        obj.GetComponent <RectTransform>().sizeDelta = new Vector2(300, 100);
                        board.boardElements[row, column]             = obj;
                        obj.transform.SetParent(lines_container.transform, true);

                        board.lines[s_rows, s_columns] = new Line();
                        LineGraphic lineGraphic = obj.GetComponent <LineGraphic>();
                        board.lines[s_rows, s_columns].InitGraphic(lineGraphic);

                        s_columns++;
                    }
                }

                if ((row + 1) % 2 == 0)
                {
                    if ((column + 1) % 2 != 0)
                    {
                        GameObject obj = Instantiate(line, pos, this.transform.rotation, this.transform);
                        obj.name = "Line " + ++count;
                        obj.GetComponent <RectTransform>().sizeDelta     = new Vector2(300, 100);
                        obj.GetComponent <RectTransform>().localRotation = new Quaternion(0, 0, 90, 90);
                        board.boardElements[row, column] = obj;
                        obj.transform.SetParent(lines_container.transform, true);

                        board.lines[s_rows, s_columns] = new Line();
                        LineGraphic lineGraphic = obj.GetComponent <LineGraphic>();
                        board.lines[s_rows, s_columns].InitGraphic(lineGraphic);

                        s_columns++;
                    }
                    if ((column + 1) % 2 == 0)
                    {
                        GameObject obj = Instantiate(text, pos, this.transform.rotation, this.transform);
                        board.boardElements[row, column] = obj;
                        board.texts.Add(obj.GetComponent <Text>());
                        obj.transform.SetParent(texts_container.transform, true);
                    }
                }
                pos = new Vector3(pos.x + distance, pos.y, pos.z);
            }
            s_columns = 0;
            s_rows++;
            pos = new Vector3(this.transform.position.x, pos.y - distance, pos.z);
        }

        PanelFit();

        board.FindSquares();
    }
Ejemplo n.º 8
0
 /// <summary>
 /// Se inicializa la parte gráfica de la línea
 /// </summary>
 /// <param name="_graphic"></param>
 public void InitGraphic(LineGraphic _graphic)
 {
     lineGraphic = _graphic;
     lineGraphic.SetLine(this);
 }