source: 2013/27/TeemuM/Game/Game/Game/Enemies.cs @ 4448

Revision 4420, 1.4 KB checked in by jumakall, 7 years ago (diff)
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Jypeli;
6using Jypeli.Assets;
7using Jypeli.Controls;
8using Jypeli.Effects;
9using Jypeli.Widgets;
10
11public class Zombie : PhysicsObject
12{
13
14    private static Image[] Images = { Game.LoadImage("Zombie1"), Game.LoadImage("Zombie2"), Game.LoadImage("Zombie3"), Game.LoadImage("Zombie4") };
15
16    private int health;
17
18    public Zombie(double widht, double height, double x, double y, int health) : base(widht, height)
19    {
20        this.X = x;
21        this.Y = y;
22        this.Shape = Shape.Circle;
23        this.health = health;
24        RandomTexture(); 
25        CreateBrain();
26
27        this.IsUpdated = true;
28    }
29
30    public void RandomTexture()
31    {
32        this.Image = Images[RandomGen.NextInt(Images.Length)];
33    }
34
35    public void Health(int healtChange)
36    {
37        health += healtChange;
38        if (health <= 0)
39            this.Destroy();
40    }
41
42    private void CreateBrain()
43    {
44        FollowerBrain brain = new FollowerBrain("player");
45        brain.Speed = 200;
46        brain.Active = true;
47        this.Brain = brain;
48    }
49
50    public override void Update(Time time)
51    {
52        this.Angle = (G.game.player.Position - this.AbsolutePosition).Normalize().Angle - Angle.FromDegrees(90);
53        base.Update(time);
54    }
55}
Note: See TracBrowser for help on using the repository browser.