Changeset 4420
- Timestamp:
- 2013-07-03 23:39:21 (10 years ago)
- Location:
- 2013/27/TeemuM/Game
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/TeemuM/Game/Game/Game/Enemies.cs
r4417 r4420 9 9 using Jypeli.Widgets; 10 10 11 public class Zombie 1: PhysicsObject11 public class Zombie : PhysicsObject 12 12 { 13 14 private static Image[] Images = { Game.LoadImage("Zombie1"), Game.LoadImage("Zombie2"), Game.LoadImage("Zombie3"), Game.LoadImage("Zombie4") }; 13 15 14 16 private int health; 15 17 16 private static Image[] Images = { Game.LoadImage("Zombie1"), Game.LoadImage("Zombie2"), Game.LoadImage("Zombie3"), Game.LoadImage("Zombie4") }; 17 18 public Zombie1(double widht, double height, double x, double y, int healt) : base(widht, height) 18 public Zombie(double widht, double height, double x, double y, int health) : base(widht, height) 19 19 { 20 20 this.X = x; 21 21 this.Y = y; 22 22 this.Shape = Shape.Circle; 23 this.health = health; 23 24 RandomTexture(); 24 25 CreateBrain(); 25 createZHealth(healt);26 26 27 27 this.IsUpdated = true; 28 28 } 29 29 30 public void createZHealth(int health) 31 { 32 this.health = health; 33 } 34 35 private void RandomTexture() 30 public void RandomTexture() 36 31 { 37 32 this.Image = Images[RandomGen.NextInt(Images.Length)]; 38 33 } 39 34 40 public void Healt (int healtChange)35 public void Health(int healtChange) 41 36 { 42 37 health += healtChange; 43 38 if (health <= 0) 44 {45 39 this.Destroy(); 46 }47 40 } 48 41 -
2013/27/TeemuM/Game/Game/Game/Game.cs
r4417 r4420 10 10 { 11 11 public static G game; 12 IntMeter scoreboard;12 private IntMeter scoreboard; 13 13 public Player player { get; private set; } 14 private List<Zombie> enemies = new List<Zombie>(); 14 15 15 16 public override void Begin() … … 43 44 else if (commands[1] == "reduce") 44 45 { 45 MessageDisplay.Add("-$" + int.Parse(commands[2]) + "!"); 46 MessageDisplay.Add("-$" + int.Parse(commands[2])); 47 } 48 } 49 else if (commands[0] == "score") 50 { 51 if (commands[1] == "add") 52 { 53 MessageDisplay.Add("+" + int.Parse(commands[2])); 54 Score(int.Parse(commands[2])); 55 } 56 else if (commands[1] == "reduce") 57 { 58 MessageDisplay.Add("-" + int.Parse(commands[2])); 59 Score(int.Parse(commands[2])); 46 60 } 47 61 } … … 70 84 else if (commands[0] == "powerup") 71 85 { 72 if (player.PowerUp(commands[1], int.Parse(commands[2])))86 if (player.PowerUp(commands[1], double.Parse(commands[2]))) 73 87 MessageDisplay.Add("Activated " + commands[1] + " powerup"); 74 88 else … … 82 96 { 83 97 for (int i = 0; i < int.Parse(commands[2]); i++) 84 createZ(); 85 } else { createZ(); } 98 SpawnZombie(); 99 } else { SpawnZombie(); } 100 } 101 } 102 else if (commands[0] == "kill") 103 { 104 if (commands[1] == "enemies") 105 { 106 KillAllEnemies(); 107 MessageDisplay.Add("All enemies killed"); 86 108 } 87 109 } … … 105 127 player = new Player(50, 50, 1, true); 106 128 Add(player); 107 createZ();129 SpawnZombie(); 108 130 } 109 131 110 void createZ()132 public void Score(int changeValue) 111 133 { 112 Zombie1 zed1 = new Zombie1(50, 50, RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top), 100); 113 Add(zed1); 134 scoreboard.Value += changeValue; 114 135 } 115 136 116 void createPlayer()137 private void SpawnZombie() 117 138 { 118 player = new Player(50, 50, 100, true); 119 Add(player); 139 Zombie zombie = new Zombie(50, 50, RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top), 100); 140 enemies.Add(zombie); 141 Add(zombie); 142 } 143 144 private void KillAllEnemies() 145 { 146 foreach (Zombie enemy in enemies) 147 { 148 enemy.Destroy(); 149 } 120 150 } 121 151 … … 123 153 { 124 154 scoreboard = new IntMeter(0); 125 scoreboard.AddOverTime(100, 10);126 127 155 Label ScoreScreen = new Label(); 128 156 ScoreScreen.X = 0; … … 134 162 } 135 163 136 private void SaveAndBackToMenu() 164 private void SaveAndBackToMenu() //ToDo: Save 137 165 { 138 166 ClearAll(); … … 148 176 menu.AddItemHandler(1, SaveAndBackToMenu); 149 177 menu.AddItemHandler(2, Exit); 178 Add(menu); 150 179 IsPaused = true; 151 Add(menu);152 153 180 } 154 181 } -
2013/27/TeemuM/Game/Game/Game/Player.cs
r4417 r4420 13 13 private static Image playerImage = Game.LoadImage("Player"); 14 14 15 Weapon weapon; 16 double speed = defaultSpeed; 17 int power = defaultPower; 18 private int _health = 0; 19 public int health 20 { 21 get 22 { 23 return _health; 24 } 25 set 26 { 27 if (value == 0) 28 Game.MessageDisplay.Add("GAME OVER!"); 29 _health = value; 30 } 31 } 15 private Weapon weapon; 16 private double speed = defaultSpeed; 17 private int health; 18 private double power = defaultPower; 32 19 33 20 public Player(double width, double height, int health, bool addDefaultControls) : base(width, height) 34 21 { 22 this.health = health; 35 23 this.Tag = "player"; 36 24 this.Shape = Shape.Rectangle; 37 25 this.Image = playerImage; 38 26 this.LinearDamping = 0.9; 39 40 this.health = health;41 27 42 28 if (addDefaultControls) … … 46 32 } 47 33 48 public bool PowerUp(String type, int value) 34 public void Health(int healthChange) //ToDo: Game over, if no more health. 35 { 36 health += healthChange; 37 } 38 39 public bool PowerUp(String type, double value) 49 40 { 50 41 if (type == "speed") 51 42 { 52 speed = defaultSpeed + value; 43 speed = defaultSpeed * value; 44 return true; 45 } 46 else if (type == "power") 47 { 48 power = defaultPower * value; 53 49 return true; 54 50 } … … 67 63 if (weapon != null) 68 64 { 65 weapon.Power.Value = power; 69 66 weapon.ProjectileCollision = ProjectileHanlder; 70 67 weapon.Angle = Angle.FromDegrees(90); … … 75 72 } 76 73 77 private void ProjectileHanlder(PhysicsObject projectile, PhysicsObject target) 74 private void ProjectileHanlder(PhysicsObject projectile, PhysicsObject target) //ToDo: Set collisions 78 75 { 79 if (target is Zombie 1)76 if (target is Zombie) 80 77 { 81 78 if (weapon is Cannon) 82 79 { 83 ((Zombie 1)target).Healt(-100);80 ((Zombie)target).Health(-100); 84 81 } 85 82 else if (weapon is PlasmaCannon) 86 83 { 87 ((Zombie 1)target).Healt(-50);84 ((Zombie)target).Health(-50); 88 85 } 89 86 } -
2013/27/TeemuM/Game/Game/GameContent/obj/x86/Debug/ContentPipeline.xml
r4381 r4420 8 8 <Processor>TextureProcessor</Processor> 9 9 <Options>None</Options> 10 <Output>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Player.xnb</Output>11 <Time>2013-07-0 3T09:02:56.8403928+03:00</Time>10 <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Player.xnb</Output> 11 <Time>2013-07-02T22:31:25.0744006+03:00</Time> 12 12 </Item> 13 13 <Item> … … 17 17 <Processor>TextureProcessor</Processor> 18 18 <Options>None</Options> 19 <Output>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie1.xnb</Output>20 <Time>2013-07-0 3T09:02:57.1104083+03:00</Time>19 <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie1.xnb</Output> 20 <Time>2013-07-02T22:59:50.6059514+03:00</Time> 21 21 </Item> 22 22 <Item> … … 26 26 <Processor>TextureProcessor</Processor> 27 27 <Options>None</Options> 28 <Output>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie2.xnb</Output>29 <Time>2013-07-0 3T09:02:57.14041+03:00</Time>28 <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie2.xnb</Output> 29 <Time>2013-07-02T22:59:50.5969509+03:00</Time> 30 30 </Item> 31 31 <Item> … … 35 35 <Processor>TextureProcessor</Processor> 36 36 <Options>None</Options> 37 <Output>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie3.xnb</Output>38 <Time>2013-07-0 3T09:02:57.3124198+03:00</Time>37 <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie3.xnb</Output> 38 <Time>2013-07-02T22:59:50.6009511+03:00</Time> 39 39 </Item> 40 40 <Item> … … 44 44 <Processor>TextureProcessor</Processor> 45 45 <Options>None</Options> 46 <Output>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie4.xnb</Output>47 <Time>2013-07-0 3T09:02:57.3194202+03:00</Time>46 <Output>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\Zombie4.xnb</Output> 47 <Time>2013-07-02T22:59:50.6029512+03:00</Time> 48 48 </Item> 49 49 <BuildSuccessful>true</BuildSuccessful> … … 53 53 <BuildConfiguration>Debug</BuildConfiguration> 54 54 <CompressContent>false</CompressContent> 55 <RootDirectory>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\GameContent\</RootDirectory>56 <LoggerRootDirectory>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\</LoggerRootDirectory>57 <IntermediateDirectory>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\GameContent\obj\x86\Debug\</IntermediateDirectory>58 <OutputDirectory>C:\Users\ Teemu\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\</OutputDirectory>55 <RootDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\GameContent\</RootDirectory> 56 <LoggerRootDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\</LoggerRootDirectory> 57 <IntermediateDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\GameContent\obj\x86\Debug\</IntermediateDirectory> 58 <OutputDirectory>C:\Users\Juho\Desktop\TeemuM\Game\Game\Game\bin\x86\Debug\Content\</OutputDirectory> 59 59 </Settings> 60 60 <Assemblies> 61 61 <Assembly> 62 62 <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</Key> 63 <Value>2013-0 6-27T12:29:42+03:00</Value>63 <Value>2013-01-29T09:47:36+02:00</Value> 64 64 </Assembly> 65 65 <Assembly> 66 66 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key> 67 <Value>2010-08-23T1 3:41:18+03:00</Value>67 <Value>2010-08-23T12:41:18+03:00</Value> 68 68 </Assembly> 69 69 <Assembly> 70 70 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll</Key> 71 <Value>2010-08-23T1 3:41:18+03:00</Value>71 <Value>2010-08-23T12:41:18+03:00</Value> 72 72 </Assembly> 73 73 <Assembly> 74 74 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll</Key> 75 <Value>2010-08-23T1 3:41:18+03:00</Value>75 <Value>2010-08-23T12:41:18+03:00</Value> 76 76 </Assembly> 77 77 <Assembly> 78 78 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll</Key> 79 <Value>2010-08-23T1 3:41:18+03:00</Value>79 <Value>2010-08-23T12:41:18+03:00</Value> 80 80 </Assembly> 81 81 <Assembly> 82 82 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll</Key> 83 <Value>2010-08-23T1 3:41:18+03:00</Value>83 <Value>2010-08-23T12:41:18+03:00</Value> 84 84 </Assembly> 85 85 <Assembly> 86 86 <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll</Key> 87 <Value>2010-08-23T1 3:41:18+03:00</Value>87 <Value>2010-08-23T12:41:18+03:00</Value> 88 88 </Assembly> 89 89 <Assembly> 90 90 <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\AnimationExtension.dll</Key> 91 <Value>2013-0 6-27T12:29:42+03:00</Value>91 <Value>2013-01-29T09:47:38+02:00</Value> 92 92 </Assembly> 93 93 <Assembly> 94 <Key>C:\ windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key>95 <Value>201 2-01-13T20:50:30.8026955+02:00</Value>94 <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 95 <Value>2011-06-27T18:29:19.4335733+03:00</Value> 96 96 </Assembly> 97 97 </Assemblies>
Note: See TracChangeset
for help on using the changeset viewer.