-
Notifications
You must be signed in to change notification settings - Fork 2
/
Knife.cs
71 lines (60 loc) · 1.82 KB
/
Knife.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
using Godot;
using System;
public class Knife : Weapon
{
public override void _Ready()
{
Damage = 40;
IdleAnimationState = AnimationPlayerManager.AnimationState.Knife_idle;
FireAnimationState = AnimationPlayerManager.AnimationState.Knife_fire;
WeaponEnabled = false;
PlayerNode = null;
}
public override void FireWeapon()
{
Area area = GetNode<Area>("Area");
var bodies = area.GetOverlappingBodies();
foreach (PhysicsBody body in bodies)
{
if (body == PlayerNode)
{
}
else if (body is HittableByBullets hittableByBullets)
{
hittableByBullets.BulletHit(Damage, area.GlobalTransform);
}
}
}
public override bool EquipWeapon()
{
if (PlayerNode.AnimationPlayer.currentState.ToString() == IdleAnimationState.ToString())
{
WeaponEnabled = true;
return true;
}
if (PlayerNode.AnimationPlayer.currentState.ToString() == "Idle_unarmed")
{
PlayerNode.AnimationPlayer.SetAnimation(AnimationPlayerManager.AnimationState.Knife_equip);
}
return false;
}
public override bool UnequipWeapon()
{
if (PlayerNode.AnimationPlayer.currentState.ToString() == IdleAnimationState.ToString())
{
if (PlayerNode.AnimationPlayer.currentState.ToString() != "Knife_unequip")
{
PlayerNode.AnimationPlayer.SetAnimation(AnimationPlayerManager.AnimationState.Knife_unequip);
}
}
if (PlayerNode.AnimationPlayer.currentState.ToString() == "Idle_unarmed")
{
WeaponEnabled = false;
return true;
}
else
{
return false;
}
}
}