2018-10-09 16:58:51 +02:00
|
|
|
using Godot;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public class Mob : RigidBody2D
|
|
|
|
{
|
|
|
|
[Export]
|
2020-01-31 08:43:50 +01:00
|
|
|
public int minSpeed; // Minimum speed range.
|
2018-10-09 16:58:51 +02:00
|
|
|
|
|
|
|
[Export]
|
2020-01-31 08:43:50 +01:00
|
|
|
public int maxSpeed; // Maximum speed range.
|
2018-10-09 16:58:51 +02:00
|
|
|
|
2020-01-31 08:43:50 +01:00
|
|
|
private String[] _mobTypes = { "walk", "swim", "fly" };
|
2018-10-09 16:58:51 +02:00
|
|
|
|
2020-01-31 08:43:50 +01:00
|
|
|
// C# doesn't have GDScript's random methods, so we use System.Random insetad.
|
|
|
|
private static Random _random = new Random();
|
2018-10-09 16:58:51 +02:00
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
GetNode<AnimatedSprite>("AnimatedSprite").Animation = _mobTypes[_random.Next(0, _mobTypes.Length)];
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnVisibilityScreenExited()
|
|
|
|
{
|
|
|
|
QueueFree();
|
|
|
|
}
|
2020-04-03 18:35:35 +02:00
|
|
|
|
|
|
|
public void OnStartGame()
|
|
|
|
{
|
|
|
|
QueueFree();
|
|
|
|
}
|
2018-10-09 16:58:51 +02:00
|
|
|
}
|