You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

170 lines
5.0 KiB

[gd_scene load_steps=12 format=2]
[ext_resource path="res://addons/randomAudioStreamPlayer/random_audio_stream_player_3D.gd" type="Script" id=1]
[ext_resource path="res://assets/sound/Steps/Metal_Footstep_02_mono.ogg" type="AudioStream" id=2]
[ext_resource path="res://assets/sound/Steps/Metal_Footstep_01_mono.ogg" type="AudioStream" id=3]
[ext_resource path="res://assets/sound/Steps/Metal_Footstep_03_mono.ogg" type="AudioStream" id=4]
[ext_resource path="res://scenes/sub_scenes/fertilizer_logo.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/sub_scenes/water_logo.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/sub_scenes/pirate_export-2.tscn" type="PackedScene" id=7]
[ext_resource path="res://scenes/sub_scenes/plants/plant_seedling_export.tscn" type="PackedScene" id=8]
[sub_resource type="GDScript" id=1]
script/source = "extends KinematicBody
var moveSpeed : float = 5.0
var sprintFactor : float = 2
var jumpForce : float = 20.0
var vel : Vector3 = Vector3()
var gravity : Vector3 = Vector3(0,-0.9,0)
onready var audio = get_node(\"RandomAudioStreamPlayer3D\")
onready var stepTimer = get_node(\"Timer\")
onready var mesh = get_node(\"MeshInstance\")
onready var fertilizer_logo = find_node(\"FertilizerLogo\")
onready var water_logo = find_node(\"WaterLogo\")
onready var seed_logo = find_node(\"SeedLogo\")
func _ready():
var err = State.connect(\"item_changed\", self, \"_on_item_changed\")
assert(not err)
func _on_item_changed():
water_logo.visible = false
fertilizer_logo.visible = false
seed_logo.visible = false
if State.player_inventory == State.ITEM.WATER:
water_logo.visible = true
elif State.player_inventory == State.ITEM.FERTILIZER:
fertilizer_logo.visible = true
elif State.player_inventory == State.ITEM.SEED:
seed_logo.visible = true
func _physics_process(_delta):
vel.x = 0
vel.z = 0
var input = Vector3()
if Input.is_action_pressed(\"MovingForward\"):
smoothRotating(180.0)
input.z -= 1
if Input.is_action_pressed(\"MovingBackward\"):
smoothRotating(0.0)
input.z += 1
if Input.is_action_pressed(\"MovingRight\"):
smoothRotating(90.0)
input.x += 1
if Input.is_action_pressed(\"MovingLeft\"):
smoothRotating(270.0)
input.x -= 1
if Input.is_action_just_pressed(\"Jump\") && is_on_floor():
input.y += 1
input = input.normalized()
if Input.is_action_pressed(\"Sprint\"):
input.x *= sprintFactor
input.z *= sprintFactor
vel += Vector3(input.x, 0, input.z)*moveSpeed
vel.y += input.y * jumpForce
vel += gravity
vel = move_and_slide(vel, Vector3.UP)
if vel.length() > 1 and is_on_floor():
if stepTimer.is_stopped():
stepTimer.start()
else:
stepTimer.stop()
func _on_Timer_timeout():
audio.play()
func smoothRotating(rot : float):
var targetRotation = lerp_angle(deg2rad(mesh.rotation_degrees.y), deg2rad(rot), 0.2)
mesh.rotation_degrees.y = rad2deg(targetRotation)
"
[sub_resource type="CylinderShape" id=2]
radius = 0.925012
height = 3.19668
[sub_resource type="Animation" id=3]
resource_name = "New Anim"
length = 1.5
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath(".:rotation_degrees")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ]
}
[node name="Player" type="KinematicBody"]
script = SubResource( 1 )
__meta__ = {
"_edit_group_": true
}
[node name="MeshInstance" parent="." instance=ExtResource( 7 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.70661, 0 )
[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 2 )
[node name="Timer" type="Timer" parent="."]
wait_time = 0.3
autostart = true
[node name="RandomAudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
bus = "Steps"
script = ExtResource( 1 )
streams = [ ExtResource( 3 ), ExtResource( 2 ), ExtResource( 4 ) ]
random_strategy = 2
randomize_volume = true
volume_min = -80.0
volume_max = -80.0
randomize_pitch = false
pitch_min = 1.0
pitch_max = 1.0
[node name="Listener" type="Listener" parent="."]
[node name="Spatial" type="Spatial" parent="."]
transform = Transform( 0.953008, 0, -0.302946, 0, 1, 0, 0.302946, 0, 0.953008, 0, 0, 0 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Spatial"]
autoplay = "New Anim"
"anims/New Anim" = SubResource( 3 )
[node name="FertilizerLogo" parent="Spatial" instance=ExtResource( 5 )]
transform = Transform( 0.41941, 0, 0.907797, 0, 1, 0, -0.907797, 0, 0.41941, 0, 3, 0 )
visible = false
[node name="WaterLogo" parent="Spatial" instance=ExtResource( 6 )]
transform = Transform( 0.901675, 0, -0.432413, 0, 1, 0, 0.432413, 0, 0.901675, 0, 3, 0 )
visible = false
[node name="SeedLogo" parent="Spatial" instance=ExtResource( 8 )]
transform = Transform( -0.978147, 0, -0.207916, 0, 1, 0, 0.207916, 0, -0.978147, 0, 2.17165, 0 )
visible = false
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]