Beispiel #1
0
        private static void AddObjectToScene(RoomScene room, short gridX, short gridY, byte objectId, byte subType = 0, Dictionary <string, short> paramList = null)
        {
            // Adjust for World Gaps
            gridX += (byte)TilemapEnum.GapLeft;
            gridY += (byte)TilemapEnum.GapUp;

            // Prepare Position
            FVector pos = FVector.Create(
                Snap.GridToPos((short)TilemapEnum.TileWidth, gridX),
                Snap.GridToPos((short)TilemapEnum.TileHeight, gridY)
                );

            GameMapper mapper = Systems.mapper;

            // Identify Object Class Type
            Type classType;
            bool hasType = mapper.ObjectTypeDict.TryGetValue(objectId, out classType);

            if (!hasType || classType == null)
            {
                return;
            }

            // Create Object
            GameObject gameObj = (GameObject)Activator.CreateInstance(classType, new object[] { room, (byte)subType, (FVector)pos, (Dictionary <string, short>)paramList });

            // Add the Object to the Scene
            if (gameObj is GameObject)
            {
                room.AddToScene((GameObject)gameObj, true);
            }
        }
Beispiel #2
0
        public static ChakramProjectile Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            ChakramProjectile projectile = ProjectilePool.ChakramProjectile.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.AssignBoundsByAtlas(2, 2, -2, -2);

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }
Beispiel #3
0
        public static SpearProjectile Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            SpearProjectile projectile = ProjectilePool.SpearProjectile.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.AssignBoundsByAtlas(5, 5, -5, -5);             // Reduce Bounds (otherwise it appears to hit too much, too quickly)
            projectile.rotation = projectile.physics.velocity.X > 0 ? 0 : Radians.Rotate180;

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }
Beispiel #4
0
        public static ProjectileBullet Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            ProjectileBullet projectile = ProjectilePool.ProjectileBullet.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.SetSafelyJumpOnTop(true);
            projectile.SetEndLife(Systems.timer.Frame + 720);
            projectile.AssignBoundsByAtlas(2, 2, -2, -2);

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }
Beispiel #5
0
        public static GrenadeProjectile Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            GrenadeProjectile projectile = ProjectilePool.GrenadeProjectile.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.SetState((byte)CommonState.Move);
            projectile.AssignBoundsByAtlas(2, 2, -2, -2);
            projectile.spinRate = projectile.physics.velocity.X > 0 ? 0.07f : -0.07f;

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }
Beispiel #6
0
        public static HammerProjectile Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            HammerProjectile projectile = ProjectilePool.HammerProjectile.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.AssignBoundsByAtlas(2, 2, -2, -2);
            projectile.rotation = Radians.UpRight + (projectile.physics.velocity.X > 0 ? 0.3f : -0.3f);
            projectile.spinRate = projectile.physics.velocity.X > 0 ? 0.10f : -0.10f;

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }
Beispiel #7
0
        public static ProjectileBolt Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            ProjectileBolt projectile = ProjectilePool.ProjectileBolt.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.AssignSubType(subType);
            projectile.AssignBoundsByAtlas(2, 2, -2, -2);

            projectile.rotation = Radians.GetRadiansBetweenCoords(0, 0, velocity.X.RoundInt, velocity.Y.RoundInt);

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }
Beispiel #8
0
        public static ProjectileEnemy Create(RoomScene room, byte subType, FVector pos, FVector velocity)
        {
            // Retrieve an available projectile from the pool.
            ProjectileEnemy projectile = ProjectilePool.ProjectileEnemy.GetObject();

            projectile.ResetProjectile(room, subType, pos, velocity);
            projectile.spinRate = projectile.physics.velocity.X > 0 ? 0.05f : -0.05f;
            projectile.AssignSubType(subType);
            projectile.AssignBoundsByAtlas(2, 2, -2, -2);
            projectile.physics.SetGravity(FInt.Create(0));

            // Add the Projectile to Scene
            room.AddToScene(projectile, false);

            return(projectile);
        }