-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKey2.cs
55 lines (42 loc) · 1.31 KB
/
Key2.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
using Godot;
using System;
using MysticRunescape;
public class Key2 : KinematicBody2D
{
// Declare member variables here. Examples:
// private int a = 2;
// private string b = "text";
private Vector2 velocity = new Vector2(0, 0);
private bool followingPlayer;
private bool pickedUp;
[Export]
public string DoorToOpen2;
public override void _Ready()
{
}
public override void _PhysicsProcess(float delta)
{
if (followingPlayer)
{
if (GameManager.Player.GetNode<AnimatedSprite>("AnimatedSprite").FlipH)
{
velocity = GameManager.Player.GetNode<Position2D>("KeyFollowLocationRight").GlobalPosition - GlobalPosition;
}
else
velocity = GameManager.Player.GetNode<Position2D>("KeyFollowLocationLeft").GlobalPosition - GlobalPosition;
}
MoveAndSlide(velocity * 5f, Vector2.Up);
}
private void _on_Area2D_body_entered(object body)
{
if (!pickedUp)
{
if (body is Adventurer)
{
followingPlayer = true;
pickedUp = true;
GameManager.Player.Keys2.Add(this);
}
}
}
}