예제 #1
0
        public new bool HasCollidedWithPlayer(SpriteUV player)         //Check if the a sprite has hit a part of the maze
        {
            if (tileIndex > 5 && tileIndex < 15)
            {
                laserOn = true;
            }
            else
            {
                laserOn = false;
            }

            Bounds2 playerBounds = player.GetlContentLocalBounds();

            player.GetContentWorldBounds(ref playerBounds);             //Get sprite bounds (player bounds)

            Bounds2 laserBounds = sprite.GetlContentLocalBounds();

            sprite.GetContentWorldBounds(ref laserBounds);             //Get all of the maze bounds

            laserBounds.Max = laserBounds.Max - 15.0f;
            laserBounds.Min = laserBounds.Min + 15.0f;

            if (playerBounds.Overlaps(laserBounds) && laserOn)
            {
                return(true);
            }

            return(false);
        }
예제 #2
0
        public bool HasCollidedWithPlayer(SpriteUV player)         //Check if the a sprite has hit a part of the maze
        {
            if (collected == false)
            {
                Bounds2 playerBounds = player.GetlContentLocalBounds();
                player.GetContentWorldBounds(ref playerBounds);                 //Get sprite bounds (player bounds)

                Bounds2 spriteBounds = sprite.GetlContentLocalBounds();
                sprite.GetContentWorldBounds(ref spriteBounds);                 //Get all of the maze bounds

                if (playerBounds.Overlaps(spriteBounds))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public bool HasCollidedWith(SpriteUV sprite)
        {
            //beam1 bounds
            Bounds2 beam1 = spinSprite[0].GetlContentLocalBounds();

            spinSprite[0].GetContentWorldBounds(ref beam1);

            //beam2 bounds
            Bounds2 beam2 = spinSprite[1].GetlContentLocalBounds();

            spinSprite[1].GetContentWorldBounds(ref beam2);

            //beam3 bounds
            Bounds2 beam3 = spinSprite[2].GetlContentLocalBounds();

            spinSprite[2].GetContentWorldBounds(ref beam3);

            //player bounds
            Bounds2 player = sprite.GetlContentLocalBounds();

            sprite.GetContentWorldBounds(ref player);

            if (player.Overlaps(beam1))
            {
                return(true);
            }

            if (player.Overlaps(beam2))
            {
                return(true);
            }

            if (player.Overlaps(beam3))
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
예제 #4
0
        public new bool HasCollidedWithPlayer(SpriteUV player)         //Check if the a sprite has hit a part of the maze
        {
            Bounds2 playerBounds = player.GetlContentLocalBounds();

            player.GetContentWorldBounds(ref playerBounds);             //Get sprite bounds (player bounds)

            Bounds2 holeBounds = sprite.GetlContentLocalBounds();

            sprite.GetContentWorldBounds(ref holeBounds);             //Get all of the maze bounds

            holeBounds.Max = holeBounds.Max - 15.0f;
            holeBounds.Min = holeBounds.Min + 15.0f;

            if (playerBounds.Overlaps(holeBounds))
            {
                return(true);
            }

            return(false);
        }
예제 #5
0
        public AmmoItem(Vector2 pos)
        {
            //assign the position of the item
            Position = pos;

            //create a new texture if one doesn't exist yet
            if (AmmoItem.ammoTexture == null)
            {
                ammoTexture = new Texture2D("/Application/data/tiles/ammo.png", false);
            }

            //create a sprite for this specific ammo item
            SpriteUV sprite = new SpriteUV();

            sprite.TextureInfo = new TextureInfo(AmmoItem.ammoTexture);
            sprite.Scale       = new Vector2(0.5f, 0.5f);
            sprite.Pivot       = new Vector2(0.5f, 0.5f);

            //rotate by a random angle
            sprite.Rotation = sprite.Rotation.Rotate(Support.random.Next(-180, 180));

            //schedule this sprite to rotate every frame by a fraction of an angle
            sprite.Schedule((dt) => {
                sprite.Rotate(0.01f);
            }, -1);

            //create an underlying shadow for the item
            SpriteUV shadow = new SpriteUV(new TextureInfo(Bullet.fireTexture));

            shadow.CenterSprite(new Vector2(0.25f, 0.25f));
            shadow.Color = Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.SetAlpha(Colors.Yellow, 0.5f);
            shadow.Scale = new Vector2(2.0f, 2.0f);

            //add a shadow and a sprite to this GameEntity
            this.AddChild(shadow);
            this.AddChild(sprite);

            //calculate the bounds of this AmmoItem
            bounds = new Bounds2();
            sprite.GetlContentLocalBounds(ref bounds);
        }
예제 #6
0
        public static void Update()
        {
            if (screenManager.IsTransitioning())
            {
                screenManager.Update(gameScene);

                // Transition Finished, load relevant data
                if (!screenManager.IsTransitioning())
                {
                    if (screenManager.GetScreen() == Screens.Game)
                    {
                        SetupGame();
                        soundManager.PlayBGM();
                    }
                    else if (screenManager.GetScreen() == Screens.GameOver)
                    {
                        gameScene.Camera2D.SetViewY(new Vector2(0.0f, Director.Instance.GL.Context.GetViewport().Height *0.5f),
                                                    new Vector2((Director.Instance.GL.Context.GetViewport().Width *0.5f), Director.Instance.GL.Context.GetViewport().Height *0.5f));
                    }
                }
            }
            else
            {
                UpdateTouchData();

                switch (screenManager.GetScreen())
                {
                case Screens.Splash:
                    screenManager.ChangeScreenTo(Screens.Menu);
                    break;

                case Screens.Game:
                    if (!tutorialManager.HasPopUp())
                    {
                        GameUpdate();
                    }
                    else
                    {
                        UpdateTouchData();
                    }
                    break;

                case Screens.GameOver:
                    Vector2 touchPos = Input2.Touch00.Pos;

                    if (touchPos.X >= 0)
                    {
                        touchPos = new Vector2((touchPos.X * 450) + 450, (touchPos.Y * 272) + 272);
                    }
                    else
                    {
                        touchPos = new Vector2(((touchPos.X + 1) * 450), ((touchPos.Y + 1) * 272));
                    }
                    Bounds2 touchBox = new Bounds2(touchPos, touchPos);
                    if (touchBox.Overlaps(rSprite.GetlContentLocalBounds()))
                    {
                        screenManager.ChangeScreenTo(Screens.Menu);
                        gameScene.RemoveChild(rSprite, false);
                    }

                    break;
                }
            }
        }
예제 #7
0
        public bool checkSides(Bounds2 player, SpriteUV sprite2, int gravity)         //ComparrightRotation = false;es 2 sprites to see is the left or right side has intersected
        {
            Bounds2 mazeTile = sprite2.GetlContentLocalBounds();

            sprite2.GetContentWorldBounds(ref mazeTile);
            if (gravity == 1)             //Down
            {
                if (((player.Point01.X < mazeTile.Point11.X) || (player.Point11.X > mazeTile.Point01.X)))
                {                                                //If the left side of the player is past the right side of the tile and vica versa
                    if ((player.Point01.Y) < mazeTile.Point01.Y) //If the tile is above the player
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else if (gravity == 2)             // Right
            {
                if (((player.Point10.Y < mazeTile.Point11.Y) || (player.Point10.Y > mazeTile.Point11.Y)))
                {                                                //If the left side of the player is past the right side of the tile and vica versa
                    if ((player.Point00.X) > mazeTile.Point00.X) //If the tile is above the player
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else if (gravity == 3)             // Up
            {
                //if (((player.Point10.X < mazeTile.Point00.X) || (player.Point00.X > mazeTile.Point10.X)))
                if (((player.Point01.X < mazeTile.Point11.X) || (player.Point11.X > mazeTile.Point01.X)))
                {                                                //If the left side of the player is past the right side of the tile and vica versa
                    if ((player.Point10.Y) > mazeTile.Point10.Y) //If the tile is above the player
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else if (gravity == 4)             // Left
            {
                if (((player.Point10.Y < mazeTile.Point11.Y) || (player.Point10.Y > mazeTile.Point11.Y)))
                {                                                //If the left side of the player is past the right side of the tile and vica versa
                    if ((player.Point11.X) < mazeTile.Point11.X) //If the tile is above the player
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
 public Bounds2 getBounds()
 {
     return(sprite.GetlContentLocalBounds());
 }