Changeset 7810 for 2016


Ignore:
Timestamp:
2016-07-05 17:39:21 (3 years ago)
Author:
tesatapa
Message:

ovi, josta vaihtaa kenttää

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/ohjaajat/VenienteFragore/VenienteFragore/VenienteFragore/VenienteFragore.cs

    r7809 r7810  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
    8  
    9  
    10  
    11  
    12  
    13  
     8using SimplePhysics; 
    149 
    1510namespace VenienteFragore 
     
    2015        private Dictionary<string, ObjectMethod> objectMethods; 
    2116 
    22         private List<Player> advenae = new List<Player>(); 
     17        private List<Player> advenae; 
    2318 
    2419        private Vector cameraSpeed = new Vector(2.0, 4.0); 
     
    3126        public override void Begin() 
    3227        { 
     28            StartLevel("thehub"); 
     29 
     30            Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     31        } 
     32 
     33 
     34 
     35        private void StartLevel(string lvlName) 
     36        { 
     37            ClearAll(); 
     38            advenae = new List<Player>(); 
    3339            objectMethods = new Dictionary<string, ObjectMethod>(); 
    3440            objectMethods.Add("ball", TestBall); 
    3541            objectMethods.Add("player", CreatePlayer); 
    3642            objectMethods.Add("moving", CreateMovingPlatform); 
    37  
    38             var tileMap = TiledTileMap.FromLevelAsset("thehub"); 
     43            objectMethods.Add("door", CreateDoor); 
     44 
     45            var tileMap = TiledTileMap.FromLevelAsset(lvlName); 
    3946            tileMap.SetTileMethod("Tiilet", TileMethod); 
    4047            tileMap.SetObjectMethod("Oliot", CreateObject); 
     
    4653            //Camera.ZoomToLevel(); 
    4754 
    48             Level.Background.Color = Color.Beige; 
    49  
    50             Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     55            Level.Background.CreateGradient(Color.Beige, Color.OrangeRed); 
    5156 
    5257            CameraInitialization(); 
     
    337342        } 
    338343 
     344 
     345        private void CreateDoor(Vector position, double width, double height, Dictionary<string, string> properties) 
     346        { 
     347           string lvlName = properties["levelName"]; 
     348            InteractableObject door = new InteractableObject(width, height); 
     349            door.Position = position; 
     350            door.Color = Color.Purple; 
     351            door.OnInteractedWith += delegate (SimplePhysics.Object actor, InteractableObject actedDoor) 
     352            { 
     353                EnterDoor(actor, actedDoor, lvlName); 
     354            }; 
     355            Add(door); 
     356        } 
     357 
     358        private void EnterDoor(SimplePhysics.Object actor, InteractableObject actedDoor, string lvlName) 
     359        { 
     360            //Tämä tänne, jotta anim. tai jotain jos joskus halutaan, muuten suoraan voi vaihtaa kenttää delegattissa 
     361            StartLevel(lvlName); 
     362        } 
     363 
    339364        private void Foreground(int x, int y, Image image, string layerName, Dictionary<string, string> properties) 
    340365        { 
Note: See TracChangeset for help on using the changeset viewer.