Example #1
0
        private bool Delete()
        {
            Vector2[] point = new Vector2[3];

            for (int index = 0; index < 3; index++)
            {
                System.Console.WriteLine(index);
                if (index == 0)
                {
                    point[index].X = xPlanePos;
                    point[index].Y = yPlanePos;
                }
                else
                {
                    point[index].X = pointTriangle[index].X;
                    point[index].Y = pointTriangle[index].Y;
                }
            }

            for (int index = asteroidList.Count - 1; index > 0; index--)
            {
                for (int i = 0; i < 3; i++)
                {
                    if (Raylib.CheckCollisionPointCircle(point[i], asteroidList[index].GetCirclePos, 60))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
        public void CheckCollision(Vector2 circleCenter, int radius)
        {
            if (Raylib.CheckCollisionPointCircle(position, circleCenter, radius))
            {
                GameData.ExplosionManager.QueueAddExplosionToList(new Explosion(position));

                if (this is AlliedMissile)
                {
                    GameData.AlliedMissileManager.QueueRemoveFromObjectList(this);
                }
                else
                {
                    CheckBaseHit(radius);

                    GameData.EnemyManager.QueueRemoveFromObjectList(this);
                    PlayerData.score += 10;
                }
            }
        }
Example #3
0
        // ta-bort-instans-av-spaceship metod
        protected bool Delete()
        {
            Vector2[] point = new Vector2[3];
            // lägger in de tre hörnen i en vector2 array med tre plattser
            for (int index = 0; index < 3; index++)
            {
                if (index == 0)
                {
                    point[index].X = xPlanePos;
                    point[index].Y = yPlanePos;
                }
                else
                {
                    point[index].X = pointTriangle[index].X;
                    point[index].Y = pointTriangle[index].Y;
                }
            }
            // tittar om någon av de tre hörnen kolliderar med asteroiden,
            // detta görs för alla asteroider i listan asteroidList
            for (int index = asteroidList.Count - 1; index > -1; index--)
            {
                for (int i = 0; i < 3; i++)
                {
                    if (Raylib.CheckCollisionPointCircle(point[i], asteroidList[index].GetCirclePos, asteroidList[index].GetAsteroidHitboxSize))
                    {
                        return(true);
                    }
                }
            }

            for (int index = LimitScreen.LimitList.Count - 1; index > -1; index--)
            {
                if (LimitScreen.LimitList[index].LimitActive && Raylib.CheckCollisionPointRec(pointTriangle[0], LimitScreen.LimitList[index].LimitRectangle))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
    public Vector2 GetStarPos()
    {
        Vector2 toReturn = new Vector2(new Random().Next(10, pluto.width - 10), new Random().Next(100, pluto.height - 100));

        if (Raylib.CheckCollisionPointCircle(toReturn, new Vector2(pluto.width / 2, pluto.height / 2), 140))
        {
            return(GetStarPos());
        }

        for (int i = 0; i < stars.Length; i++)
        {
            if (stars[i] == null)
            {
                break;
            }

            if (Vector2.Distance(toReturn, stars[i].literalPosition) < 65)
            {
                return(GetStarPos());
            }
        }

        return(toReturn);
    }
 public bool Collides(Vector2 mousePos)
 {
     return(Raylib.CheckCollisionPointCircle(mousePos, Position, Size));
 }