예제 #1
0
        private Tile CreateMovingPlatform(Vector3 position)
        {
            MovingPlatformTile platform = (MovingPlatformTile)drawnActors["MovingPlatformTile"];

            platform = platform.Clone() as MovingPlatformTile;
            platform?.InitializeCollision(position, 0.9f);
            if (platform != null)
            {
                platform.ID += id++;
            }
            objectManager.Add(platform);
            return(platform);
        }
예제 #2
0
        /// <summary>
        ///     Our Slave objects that we will later clone are all made here. Like "templates" of objects. (Like Prefabs in Unity)
        /// </summary>
        private void InitStaticModels()
        {
            /*
             * Some initialization
             */

            Color coffeeColor = new Color(111 / 255.0f, 78 / 255.0f, 55 / 255.0f, 0.95f);

            CoffeeEffectParameters coffeeEffect = new CoffeeEffectParameters(main.Effects["Coffee"],
                                                                             main.Textures["CoffeeUV"], main.Textures["CoffeeFlow"], coffeeColor);
            Transform3D            transform3D            = new Transform3D(Vector3.Zero, -Vector3.Forward, Vector3.Up);
            NormalEffectParameters normalEffectParameters = new NormalEffectParameters(main.Effects["Normal"],
                                                                                       main.Textures["Chocolate"], main.Textures["big-normalmap"],
                                                                                       main.Textures["big-displacement"], Color.White, 1, light);

            /*
             * Here we make the static Tiles.
             */

            #region StaticTiles

            //Create the Basic Tile

            Tile chocolateTile = new Tile("ChocolateTile", ActorType.Primitive, StatusType.Drawn | StatusType.Update,
                                          transform3D, normalEffectParameters, main.Models["Cube"],
                                          true, ETileType.Static);

            //Create the Plate Stacks
            BasicEffectParameters effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["Ceramic"], Color.White, 1);
            Tile plateStackTile = new Tile("plateStackTile", ActorType.Primitive, StatusType.Drawn | StatusType.Update,
                                           transform3D, effectParameters, main.Models["PlateStack"],
                                           true, ETileType.Static);

            //Create the Fork Model
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Finish"], Color.White, 1);
            OurModelObject forkModelObject =
                new OurModelObject("fork", ActorType.Decorator, StatusType.Drawn | StatusType.Update, transform3D,
                                   effectParameters, main.Models["Fork"]);
            //forkModelObject.ControllerList.Add(new RandomRotatorController("rotator", ControllerType.Curve));

            //Create the Knife Model
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Knife"], Color.White, 1);
            OurModelObject knifeModelObject =
                new OurModelObject("knife", ActorType.Decorator, StatusType.Drawn | StatusType.Update, transform3D,
                                   effectParameters, main.Models["Knife"]);
            //knifeModelObject.ControllerList.Add(new RandomRotatorController("rotator", ControllerType.Curve));

            //Create the Single Plate Model
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Finish"], Color.White, 1);
            OurModelObject singlePlateModelObject = new OurModelObject("singlePlate", ActorType.Decorator,
                                                                       StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                                       main.Models["SinglePlate"]);
            //singlePlateModelObject.ControllerList.Add(new RandomRotatorController("rotator", ControllerType.Curve));

            #endregion StaticTiles

            /*
             * Here we create the Tiles that interact with you on collision.
             */

            #region InteractableTiles

            //Create Button Tile
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Button"], Color.White, 1);
            ActivatableTile activatable = new ActivatableTile("Button", ActorType.Primitive,
                                                              StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                              main.Models["Button"], false, ETileType.Button);
            activatable.ControllerList.Add(new ColliderComponent("ButtonCC", ControllerType.Collider,
                                                                 OnActivatableCollisionEnter));

            //Create the Puddle (We call them spikes because they kill the player on collision)
            coffeeEffect = (CoffeeEffectParameters)coffeeEffect.Clone();
            coffeeEffect.UvTilesTexture = main.Textures["DropUV"];
            coffeeEffect.CoffeeColor    = new Color(new Color(239, 228, 176), 255);
            Tile spike = new Tile("Spike", ActorType.Primitive, StatusType.Drawn | StatusType.Update, transform3D,
                                  coffeeEffect, main.Models["Puddle"], false, ETileType.Spike);
            spike.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnHostileCollision));

            //Create the Mug Pickups
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Mug"], Color.White, 1);
            Tile pickup = new Tile("Mug", ActorType.Primitive, StatusType.Drawn | StatusType.Update, transform3D,
                                   effectParameters, main.Models["Mug"], false, ETileType.Star);
            pickup.ControllerList.Add(new PlayerDeathComponent("PDC", ControllerType.Event));
            pickup.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnCollectibleCollision));

            //Create the Goal Tile
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["sugarbox"], Color.White, 1);
            Tile goal = new Tile("Goal", ActorType.Primitive, StatusType.Drawn | StatusType.Update, transform3D,
                                 effectParameters, main.Models["SugarBox"], false, ETileType.Win);
            goal.ControllerList.Add(new ColliderComponent("CCG", ControllerType.Collider, OnGoalCollided));

            //Create the Checkpoint Tile
            effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["WhiteSquare"], Color.White, 1);
            Tile checkpoint = new Tile("Checkpoint", ActorType.Primitive, StatusType.Drawn | StatusType.Update,
                                       transform3D, effectParameters, main.Models["Smarties"], false, ETileType.Checkpoint);
            checkpoint.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnCheckPointCollision));

            #endregion

            /*
             * Here we create the Tiles that can Move
             */

            #region MovableTiles

            //Create the Attachable Tiles
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["SugarB"], Color.White, 1);
            AttachableTile attachableTile = new AttachableTile("AttachableTile", ActorType.Primitive,
                                                               StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                               main.Models["Cube"], ETileType.Attachable);
            attachableTile.ControllerList.Add(new TileMovementComponent("AttachableTileMC", ControllerType.Movement,
                                                                        300));
            attachableTile.ControllerList.Add(new PlayerDeathComponent("PDC", ControllerType.Event));

            //Create the Player Tile
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["SugarW"], Color.White, 1);
            PlayerTile playerTile = new PlayerTile("Player", ActorType.Player, StatusType.Drawn, transform3D,
                                                   effectParameters, main.Models["Cube"], ETileType.Player);
            playerTile.ControllerList.Add(new PlayerController("PlayerPC", ControllerType.Player, main.KeyboardManager,
                                                               main.CameraManager));
            TileMovementComponent tileMovementComponent = new TileMovementComponent("PTMC", ControllerType.Movement,
                                                                                    300);
            playerTile.ControllerList.Add(tileMovementComponent);
            playerTile.ControllerList.Add(new PlayerMovementComponent("PlayerMC", ControllerType.Movement));
            playerTile.ControllerList.Add(new PlayerDeathComponent("PDC", ControllerType.Event));

            //Create the Enemy Tiles
            coffeeColor  = new Color(coffeeColor, 255);
            coffeeEffect = new CoffeeEffectParameters(main.Effects["Coffee"], main.Textures["DropUV"],
                                                      main.Textures["CoffeeFlow"], coffeeColor);
            PathMoveTile enemy = new PathMoveTile("Enemy", ActorType.NonPlayer, StatusType.Drawn | StatusType.Update,
                                                  transform3D, coffeeEffect, main.Models["Drop"], false, ETileType.Enemy);
            enemy.ControllerList.Add(new EnemyMovementComponent("emc", ControllerType.Movement, ActivationType.AlwaysOn,
                                                                0.5f, Smoother.SmoothingMethod.Smooth));
            enemy.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnHostileCollision));

            //Create the Moving Platform Tiles
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Biscuit"], Color.White, 1);
            MovingPlatformTile movingPlatform = new MovingPlatformTile("MovingPlatform", ActorType.Platform,
                                                                       StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                                       main.Models["Biscuit"], true, ETileType.MovingPlatform);
            movingPlatform.ControllerList.Add(new PathMovementComponent("platformpmc", ControllerType.Movement,
                                                                        ActivationType.Activated, 0.5f, Smoother.SmoothingMethod.Decelerate));

            //Create the Doors Tiles
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Biscuit"], Color.White, 1);
            PathMoveTile doorTile = new PathMoveTile("Door Tile", ActorType.Platform,
                                                     StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                     main.Models["Cube"], true, ETileType.Door);
            doorTile.ControllerList.Add(new DoorMovementComponent("doorPMC", ControllerType.Movement,
                                                                  ActivationType.Activated, 0.5f, Smoother.SmoothingMethod.Accelerate));

            #endregion MovableTiles

            //Now we add them all to our dictionary to later clone.
            drawnActors = new Dictionary <string, OurDrawnActor3D>
            {
                { "StaticTile", chocolateTile },
                { "PlateStackTile", plateStackTile },
                { "AttachableBlock", attachableTile },
                { "PlayerBlock", playerTile },
                { "GoalTile", goal },
                { "EnemyTile", enemy },
                { "ButtonTile", activatable },
                { "MovingPlatformTile", movingPlatform },
                { "DoorTile", doorTile },
                { "SpikeTile", spike },
                { "StarPickupTile", pickup },
                { "CheckpointTile", checkpoint },
                { "Knife", knifeModelObject },
                { "Fork", forkModelObject },
                { "SinglePlate", singlePlateModelObject },
                { "Coffee", coffee }
            };
        }