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

Revision 4417, 1.5 KB checked in by jumakall, 9 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 Zombie1 : PhysicsObject
12{
13
14    private int health;
15
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)
19    {
20        this.X = x;
21        this.Y = y;
22        this.Shape = Shape.Circle;
23        RandomTexture(); 
24        CreateBrain();
25        createZHealth(healt);
26
27        this.IsUpdated = true;
28    }
29
30    public void createZHealth(int health)
31    {
32        this.health = health;
33    }
34
35    private void RandomTexture()
36    {
37        this.Image = Images[RandomGen.NextInt(Images.Length)];
38    }
39
40    public void Healt(int healtChange)
41    {
42        health += healtChange;
43        if (health <= 0)
44        {
45            this.Destroy();
46        }
47    }
48
49    private void CreateBrain()
50    {
51        FollowerBrain brain = new FollowerBrain("player");
52        brain.Speed = 200;
53        brain.Active = true;
54        this.Brain = brain;
55    }
56
57    public override void Update(Time time)
58    {
59        this.Angle = (G.game.player.Position - this.AbsolutePosition).Normalize().Angle - Angle.FromDegrees(90);
60        base.Update(time);
61    }
62}
Note: See TracBrowser for help on using the repository browser.