Changeset 7215 for 2016


Ignore:
Timestamp:
2016-06-09 13:40:29 (7 years ago)
Author:
sieerinn
Message:

Hahmot värjää jatkuvasti lähellä olevia palikoita

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs

    r7214 r7215  
    1313    private const double JUMPSPEED = 1250; 
    1414    private const int TILE_SIZE = 60; 
    15     private const int MATCH_LENGTH = 3; 
     15    private const int MATCH_LENGTH = 30; 
    1616 
    1717    private Player blue; 
     
    6363        ColorTileMap map = ColorTileMap.FromLevelAsset("dungeon1"); 
    6464        map.SetTileMethod(Color.Black, AddPlatform); 
    65         map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, blueColor, blueWalkImages, bluePistolpic);}); 
     65        map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate (Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, blueColor, blueWalkImages, bluePistolpic); }); 
    6666        map.SetTileMethod(Color.FromHexCode("FFD800"), CreateWeaponCrate); 
    67         map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redColor, orangeWalkImages, orangePistolpic); }); 
     67        map.SetTileMethod(Color.Red, delegate (Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redColor, orangeWalkImages, orangePistolpic); }); 
    6868        map.Execute(TILE_SIZE, TILE_SIZE); 
    6969 
     
    7575        Add(bottom); 
    7676 
     77        // Luo ajastimen, joka värittää kokoajan pelaajien lähellä olevia tiiliä. 
     78        // (pakko laittaa pieni viive, koska GetObjectsWithTag palauttaa muuten tyhjän listan) 
     79        Timer.SingleShot(0.1, () => 
     80        { 
     81            int coloringDistance = 85; 
     82            var tiles = GetObjectsWithTag("platform"); 
     83            Timer playerColorTimer = new Timer() { Interval = 0.1 }; 
     84            playerColorTimer.Timeout += () => 
     85            { 
     86                foreach (var tile in tiles) 
     87                { 
     88                    if (Vector.Distance(red.Position, tile.Position) < coloringDistance) 
     89                        ColorTile(red, (PhysicsObject)tile); 
     90                    if (Vector.Distance(blue.Position, tile.Position) < coloringDistance) 
     91                        ColorTile(blue, (PhysicsObject)tile); 
     92                } 
     93            }; 
     94            playerColorTimer.Start(); 
     95        }); 
     96 
    7797        Camera.ZoomToLevel(); 
    78  
    7998        Level.Background.Color = Color.Black; 
    8099 
     
    86105        Add(percentageBar); 
    87106 
     107        CreateMatchTimer(); 
     108    } 
     109 
     110    void CreateMatchTimer() 
     111    { 
    88112        matchTimer = new DoubleMeter(MATCH_LENGTH); 
    89113        matchTimer.LowerLimit += () => 
     
    95119        }; 
    96120 
    97         Func<double, double, Color, Label> createLabel = (double x, double y, Color color) => 
     121        Func<double, double, Color, Label> createLabel = (x, y, color) => 
    98122        { 
    99123            var label = new Label(); 
    100124            label.Font = largeFont; 
    101             label.X = x; 
    102             label.Y = y; 
     125            label.Position = new Vector(x, y); 
    103126            label.BindTo(matchTimer); 
    104127            label.TextColor = color; 
     
    111134        var timeLabel = createLabel(0, Window.Height / 2 - 100, blueColor); 
    112135 
    113         var timer = new Timer(); 
    114         timer.Interval = 1; 
    115         timer.Timeout += () => 
     136        var matchLabelTimer = new Timer(); 
     137        matchLabelTimer.Interval = 1; 
     138        matchLabelTimer.Timeout += () => 
    116139        { 
    117140            matchTimer.Value -= 1; 
    118141            timeLabel.TextColor = matchTimer.Value % 2 == 0 ? blueColor : redColor; 
    119142        }; 
    120         timer.Start(); 
     143        matchLabelTimer.Start(); 
    121144 
    122145    } 
     
    144167        player.AnimWalk = new Animation(animation) { FPS = 30 }; 
    145168        player.AnimIdle = new Animation(new[] { animation[0] }); 
    146         player.Position = paikka + new Vector(0, korkeus/2); 
     169        player.Position = paikka + new Vector(0, korkeus / 2); 
    147170        player.Spawn = player.Position; 
    148171        Add(player); 
     
    207230 
    208231        // Haluaisin tehdä tähän jonkinlaisen hauskan ponnahdusefektin jossain vaiheessa. Sellaisen napakan zoomin ja sitten boing. Hurdur. 
    209          
     232 
    210233        string victoryText = "Kiva homma hei"; 
    211234 
     
    220243        // Zoomaa voittajaan. 
    221244        double targetZoomFactor = 1.5; 
    222         var zoomTimer = new Timer(); 
    223         zoomTimer.Interval = 0.01; 
     245        var zoomTimer = new Timer() { Interval = 0.01 }; 
    224246        zoomTimer.Timeout += () => 
    225247        { 
Note: See TracChangeset for help on using the changeset viewer.