public bool CanInteract(PlayerElement player)
        {
            Rectangle playerBounds = new Rectangle((int)player.Location.X, (int)player.Location.Y, PlayerElement.PLAYER_WIDTH, PlayerElement.PLAYER_HEIGHT);
            double radius = Math.Max(texture.Width / 2.0d, texture.Height / 2.0d);
            Point center = new Point((int)this.Location.X + this.texture.Width/2, (int)this.Location.Y + this.texture.Height / 2);
            Point playerCenter = new Point(playerBounds.X + playerBounds.Width / 2, playerBounds.Y + playerBounds.Height / 2);
            List<Point> points = new List<Point>()
            {
                new Point(playerBounds.Left, playerBounds.Top),
                new Point(playerBounds.Right, playerBounds.Top),
                new Point(playerBounds.Right, playerBounds.Bottom),
                new Point(playerBounds.Left, playerBounds.Bottom),

                new Point(playerBounds.Left + playerBounds.Width / 2, playerBounds.Top),
                new Point(playerBounds.Right, playerBounds.Top  + playerBounds.Height /2),
                new Point(playerBounds.Right, playerBounds.Bottom  + playerBounds.Height /2),
                new Point(playerBounds.Left + playerBounds.Width / 2, playerBounds.Bottom),

                playerCenter
            };

            foreach(Point p in points)
            {
                if(Dist(p, center) <= radius * radius)
                {
                    return true;
                }
            }

            return false;
        }
 public void Interact(PlayerElement player)
 {
     player.CollectCoin(this);
     if (Game1.Instance.Mode == GameMode.Single || Game1.Instance.Mode == GameMode.AStar && !player.IsPlayerAGoat)
     {
         this.visible = false;
     }
 }
 public PlayerController(PlayerElement player)
 {
     this.Player = player;
     this.ActionsHistory = new List<PlayerAction>();
     this.PredefinedActions = new List<PlayerAction>();
     this.StatusHistory = new List<PlayerStatus>();
     this.ActionDuration = 300;
 }
        protected override void InitializeElements()
        {
            base.InitializeElements();

            player = new PlayerElement();
            //player.Location = new Vector2(3900, 10);
            //this.Offset = new Vector2(-3800, 0);
            this.Elements.Add(player);
        }
        public bool CanInteract(PlayerElement player)
        {
            if (!this.visible)
            {
                return false;
            }

            Rectangle playerBounds = new Rectangle((int)player.Location.X, (int)player.Location.Y, PlayerElement.PLAYER_WIDTH, PlayerElement.PLAYER_HEIGHT);
            Rectangle bounds = new Rectangle((int)this.Location.X + WIDTH / 4, (int)this.Location.Y + WIDTH / 4, WIDTH / 2, HEIGHT - WIDTH / 2);
            return bounds.Intersects(playerBounds);
        }
Exemplo n.º 6
0
 protected void HandleInteraction(PlayerElement player)
 {
     foreach (IInteractiveObject obj in GameLevelManager.CurrentLevel.InteractionObjects)
     {
         if (obj.CanInteract(player))
         {
             obj.Interact(player);
         }
     }
 }
 public PlayerNode(PlayerNode parent, GameTime time, int moves, PlayerAction action, PlayerElement playerElement, int jumps)
 {
     this.Parent = parent;
     this.Time = time;
     this.Moves = moves;
     this.Action = action;
     this.PlayerElement = playerElement;
     this.Jumps = jumps;
 }
 public void Interact(PlayerElement player)
 {
     player.Die();
 }
 public bool CanInteract(PlayerElement player)
 {
     Rectangle playerBounds = new Rectangle((int)player.Location.X, (int)player.Location.Y, PlayerElement.PLAYER_WIDTH, PlayerElement.PLAYER_HEIGHT);
     Rectangle batmanBounds = new Rectangle((int)this.Location.X + offset, (int)this.Location.Y, SPRITE_WIDTH, SPRITE_HEIGHT);
     return batmanBounds.Intersects(playerBounds);
 }
Exemplo n.º 10
0
 public bool CanInteract(PlayerElement player)
 {
     Rectangle playerBounds = new Rectangle((int)player.Location.X, (int)player.Location.Y, PlayerElement.PLAYER_WIDTH, PlayerElement.PLAYER_HEIGHT);
     Rectangle bounds = new Rectangle((int)this.Location.X, (int)this.Location.Y, COIN_WIDTH , COIN_HEIGHT);
     return bounds.Intersects(playerBounds);
 }
        public PlayerElement Clone()
        {
            PlayerElement newPlayer = new PlayerElement();

            newPlayer.Texture = this.Texture;
            newPlayer.isMoving = this.isMoving;
            newPlayer.isForward = this.isForward;
            newPlayer.isDead = this.isDead;
            newPlayer.hasWon = this.hasWon;
            newPlayer.frame = this.frame;
            newPlayer.totalTime = this.totalTime;
            newPlayer.isJumping = this.isJumping;
            newPlayer.jumpSpeed = this.jumpSpeed;
            newPlayer.Location = this.Location;
            newPlayer.coins = new HashSet<CoinElement>(this.coins);

            return newPlayer;
        }