Changeset 4424
- Timestamp:
- 2013-07-04 10:34:21 (10 years ago)
- Location:
- 2013/27/TeemuM/Game/Game/Game
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/TeemuM/Game/Game/Game/Game.cs
r4423 r4424 13 13 public Player player { get; private set; } 14 14 private List<Zombie> enemies = new List<Zombie>(); 15 //DoubleMeter LifeMeter; <-- Huono yritykseni tehdä elämä laskuria, aika loppui niin en kerennyt viimeistellä ja en ois osannukkaan, loput tohon liittyvä löytyy tiedoston pohjalta. -Aqua16 15 17 16 public override void Begin() … … 115 114 } 116 115 } 116 else if (commands[0] == "health") 117 { 118 if (commands[1] == "add") 119 { 120 player.health.Value += int.Parse(commands[2]); 121 MessageDisplay.Add("+" + commands[2] + " health"); 122 } 123 else if (commands[1] == "reduce") 124 { 125 player.health.Value -= int.Parse(commands[2]); 126 MessageDisplay.Add("-" + commands[2] + " health"); 127 } 128 } 117 129 else if (commands[0] == "exit") 118 130 { … … 133 145 AddScoreMeter(); 134 146 135 player = new Player(50, 50, 1 , true);147 player = new Player(50, 50, 10, true); 136 148 Camera.Follow(player); 137 149 Add(player); 138 150 SpawnZombie(); 151 CreateLifeMeter(); 139 152 } 140 153 … … 222 235 } 223 236 224 /*void CreateLifeMeter() 225 { 226 LifeMeter = new DoubleMeter(10); 227 LifeMeter.MaxValue = 10; 228 LifeMeter.LowerLimit += HealthDepleated; 229 237 void CreateLifeMeter() 238 { 230 239 ProgressBar LifeBar = new ProgressBar(150, 20); 231 LifeBar.X = Screen.Left + 150; 232 LifeBar.Y = Screen.Top - 20; 233 LifeBar.BindTo(LifeMeter); 240 LifeBar.X = Screen.Right - LifeBar.Width / 2 - 10; 241 LifeBar.Y = Screen.Bottom + LifeBar.Height / 2 + 10; 242 LifeBar.BorderColor = Color.Black; 243 LifeBar.BindTo(player.health); 234 244 Add(LifeBar); 235 245 } 236 237 void HealthDepleated()238 {239 MessageDisplay.Add("Elämät loppuivat, voi voi.");240 } */241 246 } -
2013/27/TeemuM/Game/Game/Game/Game.csproj
r4378 r4424 116 116 <Compile Include="Player.cs" /> 117 117 <Compile Include="Properties\AssemblyInfo.cs" /> 118 <Compile Include="UI.cs" /> 118 119 </ItemGroup> 119 120 <ItemGroup> -
2013/27/TeemuM/Game/Game/Game/Player.cs
r4420 r4424 15 15 private Weapon weapon; 16 16 private double speed = defaultSpeed; 17 p rivate inthealth;17 public IntMeter health; 18 18 private double power = defaultPower; 19 19 20 20 public Player(double width, double height, int health, bool addDefaultControls) : base(width, height) 21 21 { 22 this.health = health; 22 this.health = new IntMeter(health, 0, health); 23 //this.health.LowerLimit = 23 24 this.Tag = "player"; 24 25 this.Shape = Shape.Rectangle; … … 29 30 SetControls(Key.W, Key.S, Key.D, Key.A, MouseButton.Left); 30 31 32 G.game.AddCollisionHandler(this, PlayerCollisionHanlder); 31 33 this.IsUpdated = true; 32 34 } 33 35 34 public void Health(int healthChange) //ToDo: Game over, if no more health. 36 #region Collision handlers 37 38 private void PlayerCollisionHanlder(PhysicsObject player, PhysicsObject target) 35 39 { 36 health += healthChange; 40 if (target is Zombie) 41 { 42 health.Value -= 1; 43 } 37 44 } 45 46 private void ProjectileHanlder(PhysicsObject projectile, PhysicsObject target) //ToDo: Set collisions 47 { 48 if (target is Zombie) 49 { 50 if (weapon is Cannon) 51 { 52 ((Zombie)target).Health(-100); 53 } 54 else if (weapon is PlasmaCannon) 55 { 56 ((Zombie)target).Health(-50); 57 } 58 } 59 else if (target is Player) 60 { 61 Game.MessageDisplay.Add("Achievement get!"); 62 } 63 projectile.Destroy(); 64 } 65 66 #endregion 38 67 39 68 public bool PowerUp(String type, double value) … … 66 95 weapon.ProjectileCollision = ProjectileHanlder; 67 96 weapon.Angle = Angle.FromDegrees(90); 97 weapon.CanHitOwner = true; 68 98 this.Add(weapon); 69 99 return true; 70 100 } 71 101 return false; 72 }73 74 private void ProjectileHanlder(PhysicsObject projectile, PhysicsObject target) //ToDo: Set collisions75 {76 if (target is Zombie)77 {78 if (weapon is Cannon)79 {80 ((Zombie)target).Health(-100);81 }82 else if (weapon is PlasmaCannon)83 {84 ((Zombie)target).Health(-50);85 }86 }87 projectile.Destroy();88 102 } 89 103
Note: See TracChangeset
for help on using the changeset viewer.