CrawlingEnemy, PlantEnemy
This commit is contained in:
parent
930ff3e2bb
commit
f6758e1dba
|
@ -0,0 +1,25 @@
|
||||||
|
extends "res://Scenes/Enemies/Enemy.gd"
|
||||||
|
|
||||||
|
enum DIRECTION {LEFT = -1, RIGHT = 1}
|
||||||
|
|
||||||
|
export (DIRECTION) var WALKING_DIRECTION = DIRECTION.RIGHT
|
||||||
|
|
||||||
|
onready var floorCast = $FloorCast
|
||||||
|
onready var wallCast = $WallCast
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
wallCast.cast_to.x *= WALKING_DIRECTION
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if wallCast.is_colliding():
|
||||||
|
global_position = wallCast.get_collision_point()
|
||||||
|
var normal = wallCast.get_collision_normal()
|
||||||
|
rotation = normal.rotated(deg2rad(90)).angle()
|
||||||
|
else:
|
||||||
|
floorCast.rotation_degrees = -MAX_SPEED * 10 * WALKING_DIRECTION * delta
|
||||||
|
if floorCast.is_colliding():
|
||||||
|
global_position = floorCast.get_collision_point()
|
||||||
|
var normal = wallCast.get_collision_normal()
|
||||||
|
rotation = normal.rotated(deg2rad(90)).angle()
|
||||||
|
else:
|
||||||
|
rotation_degrees += 20 * WALKING_DIRECTION
|
|
@ -0,0 +1,65 @@
|
||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Enemies/Enemy.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://Assets/Enemies/CrawlingEnemy.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://Scenes/Enemies/CrawlingEnemy.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=3]
|
||||||
|
resource_name = "Animate"
|
||||||
|
length = 0.8
|
||||||
|
loop = true
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath("Sprite:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 0, 1, 1, 1 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 7, 3 )
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
|
extents = Vector2( 5, 2 )
|
||||||
|
|
||||||
|
[node name="CrawlingEnemy" instance=ExtResource( 1 )]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Sprite" parent="." index="0"]
|
||||||
|
position = Vector2( 0, -8 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
hframes = 4
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" parent="." index="2"]
|
||||||
|
autoplay = "Animate"
|
||||||
|
anims/Animate = SubResource( 3 )
|
||||||
|
|
||||||
|
[node name="Collider" parent="Hurtbox" index="0"]
|
||||||
|
position = Vector2( 0, -3 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Collider" parent="Hitbox" index="0"]
|
||||||
|
position = Vector2( 0, -2 )
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="FloorCast" type="RayCast2D" parent="." index="6"]
|
||||||
|
position = Vector2( 0, -4 )
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 4 )
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="WallCast" type="RayCast2D" parent="." index="7"]
|
||||||
|
position = Vector2( 0, -4 )
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 4, 0 )
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[editable path="Hurtbox"]
|
||||||
|
|
||||||
|
[editable path="Hitbox"]
|
|
@ -0,0 +1,15 @@
|
||||||
|
extends "res://Scenes/Enemies/Enemy.gd"
|
||||||
|
|
||||||
|
const EnemyBullet = preload("res://Scenes/Objects/EnemyBullet.tscn")
|
||||||
|
|
||||||
|
export (int) var BULLET_SPEED = 30
|
||||||
|
export (float) var SPREAD = 30
|
||||||
|
|
||||||
|
onready var fireDirection = $FireDirection
|
||||||
|
onready var bulletSpawnPoint = $BulletSpawnPoint
|
||||||
|
|
||||||
|
func fire_bullet():
|
||||||
|
var bullet = Utils.instance_scene_on_main(EnemyBullet, bulletSpawnPoint.global_position)
|
||||||
|
var velocity = (fireDirection.global_position - global_position).normalized() * BULLET_SPEED
|
||||||
|
velocity = velocity.rotated(deg2rad(rand_range(-SPREAD, SPREAD)))
|
||||||
|
bullet.velocity = velocity
|
|
@ -0,0 +1,76 @@
|
||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Enemies/Enemy.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://Assets/Enemies/PlantEnemy.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://Scenes/Enemies/PlantEnemy.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=1]
|
||||||
|
resource_name = "Animate"
|
||||||
|
length = 2.0
|
||||||
|
loop = true
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath("Sprite:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0, 0.1, 0.2, 0.4, 0.5, 0.6 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 0, 1, 2, 3, 4, 5 ]
|
||||||
|
}
|
||||||
|
tracks/1/type = "method"
|
||||||
|
tracks/1/path = NodePath(".")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PoolRealArray( 0.6 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"values": [ {
|
||||||
|
"args": [ ],
|
||||||
|
"method": "fire_bullet"
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
|
extents = Vector2( 8, 7 )
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id=3]
|
||||||
|
radius = 6.0
|
||||||
|
|
||||||
|
[node name="PlantEnemy" instance=ExtResource( 1 )]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Sprite" parent="." index="0"]
|
||||||
|
position = Vector2( 0, -8 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
hframes = 6
|
||||||
|
frame = 5
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" parent="." index="2"]
|
||||||
|
autoplay = "Animate"
|
||||||
|
anims/Animate = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Collider" parent="Hurtbox" index="0"]
|
||||||
|
position = Vector2( 0, -7 )
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="Collider" parent="Hitbox" index="0"]
|
||||||
|
position = Vector2( 0, -7 )
|
||||||
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
|
[node name="EnemyStats" parent="." index="5"]
|
||||||
|
max_health = 3
|
||||||
|
|
||||||
|
[node name="BulletSpawnPoint" type="Position2D" parent="." index="6"]
|
||||||
|
position = Vector2( 0, -9 )
|
||||||
|
|
||||||
|
[node name="FireDirection" type="Position2D" parent="." index="7"]
|
||||||
|
position = Vector2( 0, -14 )
|
||||||
|
|
||||||
|
[editable path="Hurtbox"]
|
||||||
|
|
||||||
|
[editable path="Hitbox"]
|
|
@ -0,0 +1,43 @@
|
||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Objects/Proyectile.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://Assets/Enemies/EnemyBullet.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=1]
|
||||||
|
resource_name = "Animate"
|
||||||
|
length = 0.6
|
||||||
|
loop = true
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath("Sprite:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0, 0.3 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 0, 1 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id=2]
|
||||||
|
radius = 2.0
|
||||||
|
|
||||||
|
[node name="EnemyBullet" instance=ExtResource( 1 )]
|
||||||
|
|
||||||
|
[node name="Sprite" parent="." index="0"]
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
hframes = 2
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" parent="." index="2"]
|
||||||
|
autoplay = "Animate"
|
||||||
|
anims/Animate = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Hitbox" parent="." index="3"]
|
||||||
|
collision_mask = 6
|
||||||
|
|
||||||
|
[node name="Collider" parent="Hitbox" index="0"]
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[editable path="Hitbox"]
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=9 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Scenes/World/TileMap.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://Scenes/World/TileMap.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://Scenes/Player/Player.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://Scenes/Player/Player.tscn" type="PackedScene" id=2]
|
||||||
|
@ -8,6 +8,8 @@
|
||||||
[ext_resource path="res://Scenes/World/Camera.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://Scenes/World/Camera.tscn" type="PackedScene" id=6]
|
||||||
[ext_resource path="res://Scenes/UI/UI.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://Scenes/UI/UI.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://Scenes/Enemies/FlyingEnemy.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://Scenes/Enemies/FlyingEnemy.tscn" type="PackedScene" id=8]
|
||||||
|
[ext_resource path="res://Scenes/Enemies/PlantEnemy.tscn" type="PackedScene" id=9]
|
||||||
|
[ext_resource path="res://Scenes/Enemies/CrawlingEnemy.tscn" type="PackedScene" id=10]
|
||||||
|
|
||||||
[node name="World" type="Node"]
|
[node name="World" type="Node"]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
@ -27,9 +29,6 @@ tile_data = PoolIntArray( 18, 0, 0, 19, 0, 5, 20, 0, 196609, 21, 0, 196609, 22,
|
||||||
[node name="MovingPlatform" parent="TileMap" instance=ExtResource( 4 )]
|
[node name="MovingPlatform" parent="TileMap" instance=ExtResource( 4 )]
|
||||||
position = Vector2( 64, 128 )
|
position = Vector2( 64, 128 )
|
||||||
|
|
||||||
[node name="WalkingEnemy" parent="." instance=ExtResource( 5 )]
|
|
||||||
position = Vector2( 32, 160 )
|
|
||||||
|
|
||||||
[node name="WalkingEnemy2" parent="." instance=ExtResource( 5 )]
|
[node name="WalkingEnemy2" parent="." instance=ExtResource( 5 )]
|
||||||
position = Vector2( 160, 208 )
|
position = Vector2( 160, 208 )
|
||||||
|
|
||||||
|
@ -41,4 +40,10 @@ position = Vector2( 448, 80 )
|
||||||
[node name="FlyingEnemy" parent="." instance=ExtResource( 8 )]
|
[node name="FlyingEnemy" parent="." instance=ExtResource( 8 )]
|
||||||
position = Vector2( 224, 88 )
|
position = Vector2( 224, 88 )
|
||||||
|
|
||||||
|
[node name="PlantEnemy" parent="." instance=ExtResource( 9 )]
|
||||||
|
position = Vector2( 136, 128 )
|
||||||
|
|
||||||
|
[node name="CrawlingEnemy" parent="." instance=ExtResource( 10 )]
|
||||||
|
position = Vector2( 72, 160 )
|
||||||
|
|
||||||
[editable path="Player"]
|
[editable path="Player"]
|
||||||
|
|
Loading…
Reference in New Issue