Changeset 7197


Ignore:
Timestamp:
2016-06-07 19:41:44 (3 years ago)
Author:
empaheik
Message:

progressbar's better, hurdur

File:
1 edited

Legend:

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

    r7195 r7197  
    1919    private Image redpic; 
    2020 
     21    DoubleMeter percentageTracker; 
     22 
    2123    public override void Begin() 
    2224    { 
     
    3537        map.SetTileMethod(Color.Black, LisaaTaso); 
    3638        map.SetTileMethod(Color.FromHexCode("#FF0026FF"), delegate(Vector paikka, double leveys, double korkeus) { blue = CreatePlayer(paikka, leveys, korkeus, bluepic, Color.Blue, new Vector(-Screen.Width / 2 + 50, Screen.Height / 2 - 50)); }); 
     39        map.SetTileMethod(Color.FromHexCode("FFD800"), CreateWeaponCrate); 
    3740        map.SetTileMethod(Color.Red, delegate(Vector paikka, double leveys, double korkeus) { red = CreatePlayer(paikka, leveys, korkeus, redpic, Color.Red, new Vector(Screen.Width / 2 - 50, Screen.Height / 2 - 50)); }); 
    3841        map.Execute(TILE_SIZE, TILE_SIZE); 
     
    4144 
    4245        Level.Background.Color = Color.Black; 
     46 
     47        percentageTracker = new DoubleMeter(0, 0, 100); 
     48 
     49        ProgressBar percentageBar = new ProgressBar(Level.Width / 2, 20) { Y = Screen.Top - 20, BarColor = red.Color, Color = blue.Color }; 
     50        percentageBar.Y = Screen.Top - 20; 
     51        percentageBar.BindTo(percentageTracker); 
     52        Add(percentageBar); 
     53    } 
     54 
     55    void CreateWeaponCrate(Vector place, double width, double height) 
     56    { 
     57        PhysicsObject crate = PhysicsObject.CreateStaticObject(width, height); 
     58        crate.Position = place; 
     59        Add(crate); 
    4360    } 
    4461 
     
    5875        Add(player); 
    5976 
    60         Label percentageLabel = new Label() { TextColor = playersColor, DecimalPlaces = 1, Position = trackerPosition}; 
     77        AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 
     78        { 
     79            ColorTile(a, b, percentageTracker); 
     80        }); 
     81 
     82    /*    Label percentageLabel = new Label() { TextColor = playersColor, DoubleFormatString = "{0:0.0}%", Position = trackerPosition}; 
    6183        Add(percentageLabel); 
    6284 
     
    6486        percentageLabel.BindTo(percentageTracker); 
    6587 
     88        percentageTracker.AddTrigger(30, TriggerDirection.Up, delegate() { Win(player); }); 
     89 
    6690        AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 
    6791        { 
    6892            ColorTile(a, b, percentageTracker); 
    6993        }); 
     94     * */ 
    7095 
    7196        return player; 
     97    } 
    7298 
     99    void Win(Player player) 
     100    { 
     101        Pause(); 
     102        //Haluaisin tehdä tähän jonkinlaisen hauskan ponnahdusefektin jossain vaiheessa. Sellaisen napakan zoomin ja sitten boing. Hurdur. 
     103       Camera.ZoomTo(player.Left, player.Bottom, player.Right, player.Top + 100); 
     104 
     105        Label announcement = new Label("Kiva homma hei") 
     106        { 
     107            TextColor = player.Color, 
     108            Position = Camera.WorldToScreen(player.Position + new Vector(0, 40)), 
     109            TextScale = new Vector(2, 2) 
     110        }; 
     111        Add(announcement); 
     112 
     113        
    73114    } 
    74115 
     
    77118        platform.Color = player.Color; 
    78119 
    79         tracker.Value = (double)GetObjects(o => o.Color == player.Color && (String)o.Tag == "platform").Count / GetObjectsWithTag("platform").Count * 100.0; 
     120        List<GameObject> colored = GetObjects(o => (o.Color == red.Color || o.Color == blue.Color) && (String)o.Tag == "platform"); 
     121        tracker.Value = (double)colored.FindAll(o => o.Color == red.Color).Count/colored.Count * 100; 
     122 
     123        //tracker.Value = (double)GetObjects(o => o.Color == player.Color && (String)o.Tag == "platform").Count / GetObjects(o => o.Color == player.Color || o.Color == blue.Color && (String)o.Tag == "platform").Count * 100.0; 
     124        //tracker.Value = (double)GetObjects(o => o.Color == player.Color && (String)o.Tag == "colored").Count / GetObjectsWithTag("platform").Count * 100.0; 
    80125    } 
    81126 
     
    93138 
    94139        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Ohjeet"); 
    95         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta"); 
     140        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta"); 
    96141    } 
    97142 
Note: See TracChangeset for help on using the changeset viewer.