-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzooientity.cs
92 lines (73 loc) · 1.99 KB
/
zooientity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using SFML.Audio;//a
namespace zooiiscool
{
class zooientity : Entity
{
float speed = 180;
Vector2 velocity = new Vector2();
public override void Start()
{
texture = "zooi.png";
position = new System.Numerics.Vector2(100, 100);
}
float FireTime = .1f;
float FireTimer = 0f;
int health = 100;
void Shoot()
{
if (FireTimer >= FireTime)
{
FireTimer = 0;
Instantiate(new Bullet(800, 1, SenderType.player), center + new Vector2(50, 0));
Audio.PlaySound("PlayerFire.wav", false);
}
}
public override void Update()
{
FireTimer += Time.DeltaTime;
rotation += Time.DeltaTime * 30;
velocity = Vector2.Zero;
if (Input.IsKeyDown("up"))
{
velocity.Y = -1;
}
if (Input.IsKeyDown("down"))
{
velocity.Y = 1;
}
if (Input.IsKeyDown("left"))
{
velocity.X = -1;
}
if (Input.IsKeyDown("right"))
{
velocity.X = 1;
}
if (Input.IsKeyDown("fire"))
{
Shoot();
}
position += velocity * Time.DeltaTime * speed;
if(health <= 0)
{
active = false;
Audio.PlaySound("GameOverSFX.wav", false);
GameManager.alive = false;
GameManager.kills = 0;
}
}
public override void OnCollision(Entity sender)
{
if(sender is Bullet)
{
var bullet = (Bullet)sender;
health -= 5;
sender.active = false;
}
}
}
}