예제 #1
0
        public void UpdateVariables() //Samlar uppdatering av variabler
        {
            light.Position = GroundPosition;
            Camera.Focus   = GroundPosition;
            float bottomHitBoxWidth = Spritesheet.SourceRectangle.Width * Scale / 5;

            bottomHitBox = new FloatRectangle(new Vector2(Position.X + ((float)Spritesheet.SourceRectangle.Width * Scale / 2) - ((float)bottomHitBoxWidth / 2),
                                                          Position.Y + (int)(Spritesheet.SourceRectangle.Height * 0.90 * Scale) - 60), new Vector2(bottomHitBoxWidth, (Spritesheet.SourceRectangle.Height * Scale) / 25));
        }
예제 #2
0
 public Creature(Spritesheet spritesheet, Vector2 position, Vector2 groundPositionOffset, Vector2 depthSortingOffset, Stats stats, Map map, Grid grid, Player player) : base(spritesheet, position, depthSortingOffset, true)
 {
     Stats  = stats;
     Map    = map;
     Grid   = grid;
     Player = player;
     this.groundPositionOffset = groundPositionOffset;
     attackHitbox   = new FloatRectangle(new Vector2(), new Vector2(attackRange, attackRange));
     GroundPosition = Position + Center + groundPositionOffset;
 }
예제 #3
0
        public GameObject(Spritesheet spritesheet, Vector2 position)
        {
            Spritesheet = spritesheet;
            Position    = position;

            Transparency = 1f;
            Scale        = 1f;
            IsActive     = true;

            Color  = Color.White;
            Hitbox = new FloatRectangle(Position, new Vector2(spritesheet.SourceRectangle.Width * Scale, spritesheet.SourceRectangle.Height * Scale));
            Center = new Vector2((float)spritesheet.SourceRectangle.Width / 2 * Scale, (float)spritesheet.SourceRectangle.Height / 2 * Scale);
        }
예제 #4
0
        public bool CheckForCollision() //Kollision med väggtile-check
        {
            int            stoppingDistance   = Map.TileSize.Y / 16;
            Vector2        estimatedHitboxPos = (GroundPosition + (direction * stoppingDistance)).ToCartesian();
            FloatRectangle hitbox             = new FloatRectangle(estimatedHitboxPos - new Vector2(bottomHitBox.Size.X / 2, 0), bottomHitBox.Size);

            for (int x = 0; x < Map.TileMap.GetLength(0); x++)
            {
                for (int y = 0; y < Map.TileMap.GetLength(1); y++)
                {
                    Vector2 tilePos = Map.GetTilePosition(new Vector2(x, y)).ToCartesian();

                    if (hitbox.Intersects(new FloatRectangle(tilePos, new Vector2(80, 80))) && Map.TileMap[x, y].TileType == TileType.Collision)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #5
0
        public Player(Spritesheet spritesheet, Vector2 position, Vector2 groundPositionOffset, Vector2 depthSortingOffset, Stats stats, Map map, Grid grid, Player player) : base(spritesheet, position, groundPositionOffset, depthSortingOffset, stats, map, grid, player)
        {
            attackRange = 150;

            light            = new PointLight();
            light.Scale      = new Vector2(1000, 1500).ToCartesian();
            light.Intensity  = 1f;
            light.ShadowType = ShadowType.Solid;
            GameManager.Instance.Penumbra.Lights.Add(light);
            Scale        = 3;
            speed        = 200f;
            LayerDepth   = 0.2f;
            bottomHitBox = new FloatRectangle(new Vector2(Position.X, Position.Y + (int)(spritesheet.SourceRectangle.Height * 0.90 * Scale)),
                                              new Vector2(spritesheet.SourceRectangle.Width * Scale, (spritesheet.SourceRectangle.Height * Scale) / 10));

            OverhealDegradeInterval = 300f;
            CanFireBall             = 0;
            spritesheet.SetFrameCount(new Point(5, 1));
            spritesheet.Interval = 100;
            hpBar = new HealthBar(stats.MaxHealth, 0.6f /*new Vector2(200, 25)*/, new Vector2(50, 50));
        }
예제 #6
0
 public bool Intersects(FloatRectangle vr) => (vr.Position.X <(Position.X + Size.X) && (vr.Position.X + vr.Size.X)> Position.X &&
                                               vr.Position.Y <(Position.Y + Size.Y) && (vr.Position.Y + vr.Size.Y)> Position.Y);
예제 #7
0
 public virtual void Update()
 {
     Spritesheet.Update();
     Hitbox = new FloatRectangle(Position, new Vector2(Spritesheet.SourceRectangle.Width * Scale, Spritesheet.SourceRectangle.Height * Scale));
     Center = new Vector2((float)Spritesheet.SourceRectangle.Width / 2 * Scale, (float)Spritesheet.SourceRectangle.Height / 2 * Scale);
 }