Пример #1
0
        private static void checkShotWallImpacts(Sprite shot)
        {
            if (shot.Expired)
            {
                return;
            }

            if (TileMap.IsWallTile(TileMap.GetSquareAtPixel(shot.WorldCenter)))//!
            {
                if (bouncesLeft > 0)
                {
                    //Ricochet shots
                    if (shot.Velocity.Y < 0 && shot.Velocity.X > 0)
                    {
                        shot.Velocity *= new Vector2(-1, -1);
                    }
                    if (shot.Velocity.Y < 0 && shot.Velocity.X < 0)
                    {
                        shot.Velocity *= new Vector2(-1, 1);
                    }
                    if (shot.Velocity.Y > 0 && shot.Velocity.X > 0)
                    {
                        shot.Velocity *= new Vector2(1, -1);
                    }
                    if (shot.Velocity.Y > 0 && shot.Velocity.X < 0)
                    {
                        shot.Velocity *= new Vector2(-1, 1);
                    }
                    else
                    {
                        shot.Velocity *= new Vector2(-1, -1);
                    }
                    bouncesLeft--;
                }
                else if (bouncesLeft <= 0)
                {
                    shot.Expired = true;    //Expire the shot
                    //Add a new Spark effect at the location of the shot
                    EffectsManager.AddSparksEffect(shot.WorldCenter, shot.Velocity);
                }
            }
        }
        private Vector2 getNewTargetSquare()
        {
            List <Vector2> path = PathFinder.FindPath(
                TileMap.GetSquareAtPixel(EnemyBase.WorldCenter),
                TileMap.GetSquareAtPixel(Player.BaseSprite.WorldCenter));

            if (path == null)
            {
                Console.WriteLine("Unable to set nodes to destination!");
                EnemySpeed = 0;
                return(EnemyBase.WorldLocation);
            }

            if (path.Count > 1)
            {
                return(new Vector2(path[1].X, path[1].Y));
            }
            else
            {
                return(TileMap.GetSquareAtPixel(Player.BaseSprite.WorldCenter));
            }
        }