Changeset 3908 for 2012/kerho
- Timestamp:
- 2012-12-08 14:56:30 (8 years ago)
- Location:
- 2012/kerho/ljov/Enter_name
- Files:
-
- 76 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/kerho/ljov/Enter_name/Enter_name/Enter_name/Enter_name.cs
r3885 r3908 12 12 13 13 [Save] int Taso; 14 int NykTaso; 15 const int MaxTaso = 4; //KASVATA KUN LISÄÄT TASOJA 14 16 15 17 public Image pelaajanKuva = LoadImage("norsu"); … … 22 24 public override void Begin() 23 25 { 26 if (DataStorage.Exists("save.xml")) LoadGame("save.xml"); else Taso = 0; 27 Valikko(); 28 } 29 30 public void Valikko() 31 { 32 Label label = new Label("GRAFFUT ON PLACEHOLDEREITA"); 33 label.Position = new Vector(Screen.Right - 200, Screen.Top - 30); 34 label.TextColor = Color.Red; 35 Add(label); 36 37 NykTaso = Taso; 38 39 MultiSelectWindow alku = new MultiSelectWindow("..", "Pelaa", "Kentät", "Lopeta"); 40 alku.AddItemHandler(0, Aloita); 41 alku.AddItemHandler(1, valitseKentta); 42 alku.AddItemHandler(2, Lopeta); 43 alku.DefaultCancel = -1; 44 Add(alku); 45 } 46 void valitseKentta() 47 { 48 MultiSelectWindow kentat = new MultiSelectWindow("Valitse kenttä", "1", "2", "3", "4", "5", "Alkuun"); 49 kentat.AddItemHandler(0, delegate { if (Taso >= 0) { NykTaso = 0; Aloita(); } else {valitseKentta();}}); 50 kentat.AddItemHandler(1, delegate { if (Taso >= 1) { NykTaso = 1; Aloita(); } else {valitseKentta();}}); 51 kentat.AddItemHandler(2, delegate { if (Taso >= 2) { NykTaso = 2; Aloita(); } else { valitseKentta();}}); 52 kentat.AddItemHandler(3, delegate { if (Taso >= 3) { NykTaso = 3; Aloita(); } else { valitseKentta();}}); 53 kentat.AddItemHandler(4, delegate { if (Taso >= 4) { NykTaso = 4; Aloita(); } else { valitseKentta(); } }); 54 kentat.AddItemHandler(5, Valikko); 55 kentat.DefaultCancel = 5; 56 Add(kentat); 57 } 58 public void Aloita() 59 { 60 ClearAll(); 61 Label label = new Label("GRAFFUT ON PLACEHOLDEREITA"); 62 label.Position = new Vector(Screen.Right - 200, Screen.Top - 30); 63 label.TextColor = Color.Red; 64 Add(label); 65 24 66 hemmo = new Hemmo(); 25 67 26 if (DataStorage.Exists("save.xml")) LoadGame("save.xml"); else Taso = 0;27 28 68 Gravity = new Vector(0, -1000); 29 69 30 70 Camera.Follow(hemmo); 31 Camera.ZoomFactor = 0.9;71 Camera.ZoomFactor = 1.2; 32 72 Camera.StayInLevel = true; 33 73 … … 35 75 Mouse.ListenMovement(0.1, hemmo.Tahtaa, ""); 36 76 Mouse.Listen(MouseButton.Left, ButtonState.Down, Toimi, ""); 37 77 Keyboard.Listen(Key.A, ButtonState.Down, Vasen, ""); 38 78 Keyboard.Listen(Key.D, ButtonState.Down, Oikea, ""); 39 79 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppy, ""); 40 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Pause, ""); 41 42 Valikko(); 43 } 44 45 public void Valikko() 46 { 47 MultiSelectWindow alku = new MultiSelectWindow("..", "Pelaa", "Kentät", "Lopeta"); 48 alku.AddItemHandler(0, Aloita); 49 50 alku.AddItemHandler(2, Exit); 51 alku.DefaultCancel = -1; 52 Add(alku); 53 } 54 55 public void Aloita() 56 { 57 LataaKentta(Taso); 80 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Pause, ""); 81 82 LataaKentta(NykTaso); 58 83 } 59 84 … … 63 88 kentta.SetTileMethod('0', LisaaTuhottava); 64 89 kentta.SetTileMethod('#', LisaaTaso); 65 kentta.SetTileMethod('V', LisaaAnsa); 66 kentta.SetTileMethod('*', LisaaLoota); 90 kentta.SetTileMethod('_', LisaaAnsa); 91 kentta.SetTileMethod('H', LisaaLoota); 92 kentta.SetTileMethod('*', LisaaMaali); 67 93 kentta.SetTileMethod('N', LisaaPelaaja); 68 94 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); … … 96 122 void LisaaLoota(Vector paikka, double leveys, double korkeus) 97 123 { 98 Loota loota = new Loota((int)leveys, (int)korkeus, 20,20);124 Loota loota = new Loota((int)leveys, (int)korkeus,10,10); 99 125 loota.IgnoresCollisionResponse = true; 100 126 loota.Tag = "laatikko"; … … 103 129 Add(loota, -1); 104 130 } 131 void LisaaMaali(Vector paikka, double leveys, double korkeus) 132 { 133 PhysicsObject maali = PhysicsObject.CreateStaticObject(leveys, korkeus * 0.1); 134 paikka.Y -= korkeus / 2; 135 maali.Position = paikka; 136 maali.Color = Color.Green; 137 maali.Tag = "Today is ours"; 138 Add(maali); 139 } 105 140 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 106 141 { 107 142 hemmo.Position = paikka; 108 if (hemmo.IsAddedToGame)109 {110 Remove(hemmo);111 Remove(hemmo.Ase);112 RemoveCollisionHandlers(hemmo, null, null, null);113 }114 143 Add(hemmo); 115 144 Add(hemmo.Ase); … … 123 152 Label Ammocount = new Label(); 124 153 Ammocount.BindTo(hemmo.Ase.Ammo); 154 Ammocount.Position = new Vector(Screen.Left + 150, Screen.Top -30); 125 155 Add(Ammocount); 126 156 … … 147 177 Add(pause); 148 178 } 149 179 public void Edistys() 180 { 181 hemmo.Destroy(); 182 hemmo.Ase.Destroy(); 183 if (NykTaso != MaxTaso) 184 { 185 if (Taso == NykTaso) Taso++; 186 MultiSelectWindow edistys = new MultiSelectWindow("Läpäisit tason!", "Seuraava", "Uudelleen", "Alkuun"); 187 edistys.AddItemHandler(1, Aloita); 188 edistys.AddItemHandler(0, delegate { NykTaso++; Aloita(); }); 189 edistys.AddItemHandler(2, Valikko); 190 Add(edistys); 191 } 192 else 193 { 194 MultiSelectWindow edistys = new MultiSelectWindow("Voitit pelin!", "Uudelleen", "Alkuun"); 195 edistys.AddItemHandler(0, Aloita); 196 edistys.AddItemHandler(1, Valikko); 197 Add(edistys); 198 } 199 } 150 200 public void Kuolema() 151 201 { 202 hemmo.Destroy(); 203 hemmo.Ase.Destroy(); 152 204 MultiSelectWindow kuollut = new MultiSelectWindow("Kuolit!", "Uudelleen", "Alkuun"); 153 205 kuollut.AddItemHandler(0, Aloita); … … 156 208 } 157 209 210 void Lopeta() 211 { 212 SaveGame("save.xml"); 213 Exit(); 214 } 215 158 216 protected override void Update(Microsoft.Xna.Framework.GameTime gameTime) 159 217 { 160 base.Update(gameTime); //MITÄS *****218 base.Update(gameTime); 161 219 if (hemmo != null)hemmo.Ase.Position = hemmo.Position; 162 220 } -
2012/kerho/ljov/Enter_name/Enter_name/Enter_name/Hemmo.cs
r3885 r3908 9 9 class Hemmo : PlatformCharacter 10 10 { 11 public IntMeter hp = new IntMeter(40);11 public IntMeter hp; 12 12 13 13 public AssaultRifle Ase; 14 bool kuollut = false;15 14 16 15 const int MaxAmmo = 40; … … 20 19 : base(50, 50) 21 20 { 21 CollisionIgnoreGroup = 1; 22 22 23 Image = Game.LoadImage("norsu"); 23 24 Mass = 10; 24 25 26 hp = new IntMeter(40); 25 27 hp.MaxValue = 40; 26 28 27 this.CollisionIgnoreGroup = 1; 28 29 Ase = null; 29 30 Ase = new AssaultRifle(60, 30); 30 31 Ase.Power.DefaultValue = 50; … … 79 80 hp.Value -= 1; 80 81 if (hp <= 0) 81 if82 (!kuollut)83 {84 82 (this.Game as Enter_name).Kuolema(); 85 kuollut = true;86 }87 83 } 88 84 else if (kohde.Tag.ToString() == "TuhoaMinut") … … 95 91 if (kohde.Tag.ToString() == "Consequence for failure") 96 92 { 97 if (!kuollut)98 93 (this.Game as Enter_name).Kuolema(); 99 kuollut = true; 94 } 95 if (kohde.Tag.ToString() == "Today is ours") 96 { 97 (this.Game as Enter_name).Edistys(); 100 98 } 101 99 else if (kohde.Tag.ToString() == "laatikko") -
2012/kerho/ljov/Enter_name/Enter_name/Enter_nameContent/Enter_nameContent.contentproj
r3885 r3908 62 62 </ItemGroup> 63 63 <ItemGroup> 64 <Compile Include="kenttabu1.txt"> 65 <Name>kenttabu1</Name> 66 <Importer>TextFileImporter</Importer> 67 <Processor>TextFileContentProcessor</Processor> 68 </Compile> 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="1.txt"> 72 <Name>1</Name> 73 <Importer>TextFileImporter</Importer> 74 <Processor>TextFileContentProcessor</Processor> 75 </Compile> 76 </ItemGroup> 77 <ItemGroup> 78 <Compile Include="2.txt"> 79 <Name>2</Name> 80 <Importer>TextFileImporter</Importer> 81 <Processor>TextFileContentProcessor</Processor> 82 </Compile> 83 </ItemGroup> 84 <ItemGroup> 85 <Compile Include="4.txt"> 86 <Name>4</Name> 87 <Importer>TextFileImporter</Importer> 88 <Processor>TextFileContentProcessor</Processor> 89 </Compile> 90 </ItemGroup> 91 <ItemGroup> 64 92 <Compile Include="0.txt"> 65 93 <Name>0</Name> … … 69 97 </ItemGroup> 70 98 <ItemGroup> 71 <Compile Include=" kenttabu1.txt">72 <Name> kenttabu1</Name>99 <Compile Include="3.txt"> 100 <Name>3</Name> 73 101 <Importer>TextFileImporter</Importer> 74 102 <Processor>TextFileContentProcessor</Processor>
Note: See TracChangeset
for help on using the changeset viewer.