- Timestamp:
- 2016-06-07 19:41:44 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/23/ohjaajat/Punasininen/Punasininen/Punasininen/Punasininen.cs
r7195 r7197 19 19 private Image redpic; 20 20 21 DoubleMeter percentageTracker; 22 21 23 public override void Begin() 22 24 { … … 35 37 map.SetTileMethod(Color.Black, LisaaTaso); 36 38 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); 37 40 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)); }); 38 41 map.Execute(TILE_SIZE, TILE_SIZE); … … 41 44 42 45 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); 43 60 } 44 61 … … 58 75 Add(player); 59 76 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}; 61 83 Add(percentageLabel); 62 84 … … 64 86 percentageLabel.BindTo(percentageTracker); 65 87 88 percentageTracker.AddTrigger(30, TriggerDirection.Up, delegate() { Win(player); }); 89 66 90 AddCollisionHandler(player, "platform", delegate(PhysicsObject a, PhysicsObject b) 67 91 { 68 92 ColorTile(a, b, percentageTracker); 69 93 }); 94 * */ 70 95 71 96 return player; 97 } 72 98 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 73 114 } 74 115 … … 77 118 platform.Color = player.Color; 78 119 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; 80 125 } 81 126 … … 93 138 94 139 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"); 96 141 } 97 142
Note: See TracChangeset
for help on using the changeset viewer.