Changeset 4406
- Timestamp:
- 2013-07-03 14:45:40 (10 years ago)
- Location:
- 2013/27/AkseliJ/Levypallo/Levypallo/Levypallo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/AkseliJ/Levypallo/Levypallo/Levypallo/Kuutio.cs
r4390 r4406 10 10 { 11 11 12 public Kuutio(int indexY, int indexX, Color vari) 12 internal int health; 13 14 public static Color[] healthvarit = { Color.Green, Color.Red, Color.Purple, Color.Yellow, Color.Brown }; 15 16 public Kuutio(int indexY, int indexX, int health) 13 17 : base(100, 100) 14 18 { … … 17 21 18 22 19 Color = vari; 23 this.health = health; 24 Color = healthvarit[health - 1]; 20 25 X = indexX * 100 +50; 21 26 Y = (indexY + 2) * 100 + 50; -
2013/27/AkseliJ/Levypallo/Levypallo/Levypallo/Levypallo.cs
r4390 r4406 52 52 taulu.Text = "LEVYPALLO SCORE: \n" + Score.ToString()+"\n"+"Elämiä jäljellä:\n"+elamat; 53 53 if (!palloKiinni) 54 { 55 pallo.CanRotate = true; 54 56 pallo.Velocity = pallo.Velocity.Normalize() * Pallon_nopeus; 55 else pallo.Velocity = levy.Velocity; 57 } 58 else { pallo.Velocity = levy.Velocity; 59 pallo.StopAngular(); 60 pallo.Angle = Angle.Zero; 61 62 } 56 63 if (pallo.Y <= Level.Bottom + 30) { 57 64 … … 62 69 elamat--; 63 70 } 71 64 72 if (elamat <= 0) 65 73 { 66 Score = 0; 67 68 } 69 74 Label l = new Label(600, 400, "Game Over"); 75 l.TextScale = new Vector(6, 6); 76 l.TextColor = Color.White; 77 MessageDisplay.Add(ArvioiTulos()); 78 Add(l); 79 Pause(); 80 81 82 } 83 84 } 85 86 private string ArvioiTulos() 87 { 88 if (Score < 1000) 89 return "EI VOI OLLA TOTTA! Vain "+Score+" pistettä!?!?! Miten se on mahdollista?"; 90 91 else if (Score < 2000) 92 93 return Score + " pisteitä ei ole kovin häävi. Yritä kuitenkin uudelleen!"; 94 95 96 97 else if (Score > 4000) { 98 99 return "Vaikuttavaa! Mistä sait nuo taidot? "+Score+" on aika hyvä tulos :)"; 100 } 101 else if (Score > 8000) { 102 103 return "ANTAKAA APLODIT UUDELLE LEVYPALLOMESTARILLE! "+Score+" PISTETTÄ!"; 104 105 } 106 107 return "Hmm... Ihan ok - "+Score+" pistettä."; 70 108 } 71 109 … … 75 113 } 76 114 77 private void KuutioonIskee(PhysicsObject bollen, PhysicsObject kuutio) { 78 79 if (kuutio is Kuutio) { 115 private void KuutioonIskee(PhysicsObject bollen, PhysicsObject kuutio) 116 { 117 118 if (kuutio is Kuutio) 119 { 80 120 81 121 Score += 50; 82 122 Kuutio cube = kuutio as Kuutio; 83 84 85 //Explosion KABOOOOOOOOOOM = new Explosion(100); 86 //KABOOOOOOOOOOM.X = cube.X; 87 //KABOOOOOOOOOOM.Y = cube.Y; 88 cube.Destroy(); 89 //Add(KABOOOOOOOOOOM); 90 91 } 92 93 123 cube.health--; 124 125 126 127 Explosion KABOOOOOOOOOOM = new Explosion(100); 128 KABOOOOOOOOOOM.X = cube.X; 129 KABOOOOOOOOOOM.Y = cube.Y; 130 KABOOOOOOOOOOM.UseShockWave = false; 131 Add(KABOOOOOOOOOOM); 132 if (cube.health <= 0) cube.Destroy(); 133 134 135 if(cube.health > 0) 136 cube.Color = Kuutio.healthvarit[cube.health - 1]; 137 138 139 } 94 140 } 95 141 … … 101 147 Keyboard.Listen<Key, ButtonState>(Key.Right, ButtonState.Up, NappiYlos, null, Key.Right, ButtonState.Up); 102 148 Keyboard.Listen<Key, ButtonState>(Key.Left, ButtonState.Up, NappiYlos, null, Key.Left, ButtonState.Up); 149 Keyboard.Listen<Key, ButtonState>(Key.K, ButtonState.Pressed, NappiYlos, null, Key.K, ButtonState.Pressed); 103 150 } 104 151 105 152 private void LuoLevy() 106 153 { 154 //Oletusleveys 250 107 155 levy = PhysicsObject.CreateStaticObject(250, 40); 108 156 levy.Color = Color.Yellow; … … 139 187 140 188 } 141 if (tila == ButtonState.Pressed && nappi == Key.Space && palloKiinni) 142 { 143 palloKiinni = false; 144 pallo.IgnoresCollisionResponse = false; 145 bool rnd = RandomGen.NextBool(); 146 if (rnd) pallo.Velocity = new Vector(300, 300); 147 else pallo.Velocity = new Vector(-300, 300); 189 if (tila == ButtonState.Pressed) 190 { 191 192 if (nappi == Key.Space && palloKiinni) 193 { 194 palloKiinni = false; 195 pallo.IgnoresCollisionResponse = false; 196 bool rnd = RandomGen.NextBool(); 197 if (rnd) pallo.Velocity = new Vector(300, 300); 198 else pallo.Velocity = new Vector(-300, 300); 199 } 200 else if (nappi == Key.K && !palloKiinni) { 201 202 palloKiinni = true; 203 pallo.X = levy.X; 204 pallo.Y = Level.Bottom + 70; 205 pallo.IgnoresCollisionResponse = true; 206 elamat--; 207 208 } 209 210 148 211 149 212 } … … 170 233 171 234 172 kentta[i, j] = new Kuutio(((int)Level.Bottom / 100) + i, (((int)Level.Left / 100) + j), RandomGen.Next Color());235 kentta[i, j] = new Kuutio(((int)Level.Bottom / 100) + i, (((int)Level.Left / 100) + j), RandomGen.NextInt(1, 6)); 173 236 } 174 237 else kentta[i, j] = null; … … 186 249 pallo.Y = Level.Bottom + 70; 187 250 pallo.X= 0; 188 pallo.Shape = Shape. Circle;251 pallo.Shape = Shape.Octagon; 189 252 pallo.Restitution = 1.5; 190 253 pallo.IgnoresGravity = true; 191 254 pallo.Tag = "pallo"; 192 255 pallo.IgnoresCollisionResponse = true; 256 pallo.IgnoresExplosions = true; 193 257 palloKiinni = true; 194 258 Add(pallo); … … 220 284 221 285 } 286 287 222 288 }
Note: See TracChangeset
for help on using the changeset viewer.