Beispiel #1
0
 /// <summary>
 /// Reset the object to the state of the beginning of the level
 /// </summary>
 public void Reset()
 {
     // use the public one to set the boundingbox
     Position         = StartPosition;
     currentPosinList = -1;
     curMovement      = Player.Movement.Dead;
 }
        Rectangle wSize; // = Game1.Instance.fontRenderer.StringSize("W");

        #endregion Fields

        #region Constructors

        public MovementTile(Rectangle size, Player.Movement movement, bool levelCreator = false)
            : base(size)
        {
            inLevelCreator = levelCreator;
            movedrirection = movement;

            wSize = Game1.Instance.fontRenderer.CharSize;

            if (levelCreator)
            {
                switch (movement)
                {
                    case Player.Movement.Right:
                        rotation = MathHelper.ToRadians(0.0f);
                        break;
                    case Player.Movement.Down:
                        rotation = MathHelper.ToRadians(90.0f);
                        break;
                    case Player.Movement.Left:
                        rotation = MathHelper.ToRadians(180.0f);
                        break;
                    case Player.Movement.Up:
                        rotation = MathHelper.ToRadians(270.0f);
                        break;
                    default:
                        rotation = 0;
                        movement = Player.Movement.Idle;
                        break;
                }
            }
        }
Beispiel #3
0
        public MovementTile(Rectangle size, Player.Movement movement, bool levelCreator = false)
            : base(size)
        {
            inLevelCreator = levelCreator;
            movedrirection = movement;

            wSize = Game1.Instance.fontRenderer.CharSize;

            if (levelCreator)
            {
                switch (movement)
                {
                case Player.Movement.Right:
                    rotation = MathHelper.ToRadians(0.0f);
                    break;

                case Player.Movement.Down:
                    rotation = MathHelper.ToRadians(90.0f);
                    break;

                case Player.Movement.Left:
                    rotation = MathHelper.ToRadians(180.0f);
                    break;

                case Player.Movement.Up:
                    rotation = MathHelper.ToRadians(270.0f);
                    break;

                default:
                    rotation = 0;
                    movement = Player.Movement.Idle;
                    break;
                }
            }
        }
        public override void Update(GameTime time)
        {
            if (InputHelper.Instance.IsKeyPressed(Keys.A))
            {
                rotation = MathHelper.ToRadians(180.0f);
            }
            else if (InputHelper.Instance.IsKeyPressed(Keys.D))
            {
                rotation = MathHelper.ToRadians(0.0f);
            }
            else if (InputHelper.Instance.IsKeyPressed(Keys.S))
            {
                rotation = MathHelper.ToRadians(90.0f);
            }
            else if (InputHelper.Instance.IsKeyPressed(Keys.W))
            {
                rotation = MathHelper.ToRadians(270.0f);
            }

            if (InputHelper.Instance.IsLeftMousePressed())
            {
                //MovementTile win = new MovementTile(new Rectangle((int)InputHelper.Instance.MousePos().X, (int)InputHelper.Instance.MousePos().X, 32, 32), GetMovement(), true);
                //movement.Add(win);

                Player.Movement move = GetMovement();

                if (!dragging)
                {
                    dragging        = true;
                    tileSize.X      = (int)InputHelper.Instance.MousePos().X;
                    tileSize.Y      = (int)InputHelper.Instance.MousePos().Y;
                    tileSize.Width  = (int)Math.Abs(InputHelper.Instance.MousePos().X - tileSize.X);
                    tileSize.Height = (int)Math.Abs(InputHelper.Instance.MousePos().Y - tileSize.Y);
                }
            }
            else if (InputHelper.Instance.LeftMouseDown())
            {
                tileSize.Width  = (int)Math.Abs(InputHelper.Instance.MousePos().X - tileSize.X);
                tileSize.Height = (int)Math.Abs(InputHelper.Instance.MousePos().Y - tileSize.Y);
            }
            else if (InputHelper.Instance.IsLeftMouseReleased() && dragging)
            {
                MovementTile win = new MovementTile(tileSize, GetMovement(), true);
                movement.Add(win);
                dragging = false;
            }
            else if (InputHelper.Instance.IsRightMousePressed() && !dragging)
            {
                for (int i = 0; i < movement.Count; i++)
                {
                    MovementTile o = movement[i];

                    if (o.Boundingbox.Contains(InputHelper.Instance.MousePos().toPoint()))
                    {
                        movement.Remove(o);
                    }
                }
            }

            // check for left mouse up
            if (!InputHelper.Instance.LeftMouseDown())
            {
                dragging = false;
                if (!dragging)
                {
                    tileSize.X = (int)InputHelper.Instance.MousePos().X;
                    tileSize.Y = (int)InputHelper.Instance.MousePos().Y;
                }
            }


            if (dragging)
            {
                blockLayerChange = true;
                tileSize         = GetInvertedRectangle(tileSize);
            }
            else
            {
                blockLayerChange = false;
            }


            base.Update(time);
        }
Beispiel #5
0
 public void ChangeMovement(Player.Movement mov)
 {
     curMovement = mov;
 }
    void SpawnPlayers()
    {
        Player.Movement tempPlayer = ((GameObject)Instantiate(playersPrefabs[0], new Vector3(-14f, -0.54f, 10.0f), Quaternion.identity)).GetComponent <Player.Movement>();
        tempPlayer.colIndex = 2;
        tempPlayer.rowIndex = 2;
        players.Add(tempPlayer);
        tempPlayer.bot = false;
        int rand = Random.Range(1, 3);

        switch (rand)
        {
        case 1:
            tempPlayer.gameObject.transform.localEulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
            break;

        case 2:
            tempPlayer.gameObject.transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
            break;
        }

        Player.Movement tempPlayer2 = ((GameObject)Instantiate(playersPrefabs[1], new Vector3(-15f, -0.54f, 10.0f), Quaternion.identity)).GetComponent <Player.Movement>();
        tempPlayer2.colIndex = 1;
        tempPlayer2.rowIndex = 2;
        players.Add(tempPlayer2);
        tempPlayer2.bot = true;
        rand            = Random.Range(1, 3);
        switch (rand)
        {
        case 1:
            tempPlayer2.gameObject.transform.localEulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
            break;

        case 2:
            tempPlayer2.gameObject.transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
            break;
        }

        Player.Movement tempPlayer3 = ((GameObject)Instantiate(playersPrefabs[2], new Vector3(-14f, -0.54f, 11.0f), Quaternion.identity)).GetComponent <Player.Movement>();
        tempPlayer3.colIndex = 2;
        tempPlayer3.rowIndex = 1;
        players.Add(tempPlayer3);
        tempPlayer3.bot = true;
        rand            = Random.Range(1, 3);
        switch (rand)
        {
        case 1:
            tempPlayer3.gameObject.transform.localEulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
            break;

        case 2:
            tempPlayer3.gameObject.transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
            break;
        }

        Player.Movement tempPlayer4 = ((GameObject)Instantiate(playersPrefabs[3], new Vector3(-15f, -0.54f, 11.0f), Quaternion.identity)).GetComponent <Player.Movement>();
        tempPlayer4.colIndex = 1;
        tempPlayer4.rowIndex = 1;
        players.Add(tempPlayer4);
        tempPlayer4.bot = true;
        rand            = Random.Range(1, 3);
        switch (rand)
        {
        case 1:
            tempPlayer4.gameObject.transform.localEulerAngles = new Vector3(0.0f, 90.0f, 0.0f);
            break;

        case 2:
            tempPlayer4.gameObject.transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
            break;
        }
    }
Beispiel #7
0
 /// <summary>
 /// Reset the object to the state of the beginning of the level
 /// </summary>
 public void Reset()
 {
     // use the public one to set the boundingbox
     Position = StartPosition;
     currentPosinList = -1;
     curMovement = Player.Movement.Dead;
 }
Beispiel #8
0
 public void ChangeMovement(Player.Movement mov)
 {
     curMovement = mov;
 }
Beispiel #9
0
 /// <summary>
 /// Connect important objects and get camera size
 /// </summary>
 void Awake()
 {
     playerMove = FindObjectOfType <Player.Movement>();
     trunks     = FindObjectOfType <TrunkManager>();
     camSize    = gameObject.GetComponent <Camera>().orthographicSize;
 }