1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-21 23:34:21 +00:00

Add actual pea shooting

This commit is contained in:
Ichicoro 2023-01-08 12:29:41 +01:00
parent 45f79ed68a
commit 2b2218bcf1
5 changed files with 51 additions and 11 deletions

View file

@ -1,4 +1,5 @@
extends Node3D
class_name CropTile
signal on_planted()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://bg88gc1w1gw5m"]
[gd_scene load_steps=17 format=3 uid="uid://bg88gc1w1gw5m"]
[ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_agjfy"]
[ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="1_w6ara"]
@ -22,15 +22,23 @@ shader_parameter/sea = ExtResource("1_w6ara")
material = SubResource("ShaderMaterial_3uyyi")
size = Vector2(1000, 1000)
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_htlhh"]
sky_top_color = Color(0.356863, 0.623529, 0.937255, 1)
sky_horizon_color = Color(0.254902, 0.623529, 0.8, 1)
ground_bottom_color = Color(0.254902, 0.623529, 0.8, 1)
ground_horizon_color = Color(0.254902, 0.623529, 0.8, 1)
ground_curve = 7.89838
[sub_resource type="Gradient" id="Gradient_shcpx"]
interpolation_mode = 2
offsets = PackedFloat32Array(0.518605, 0.723256, 0.953488)
colors = PackedColorArray(1, 0.694118, 0.741176, 1, 0.0352941, 0.831373, 0.882353, 1, 0.152941, 0.698039, 1, 1)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_yb0rj"]
gradient = SubResource("Gradient_shcpx")
width = 256
height = 256
fill_from = Vector2(0, 1)
fill_to = Vector2(0, 0)
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_c0cxy"]
panorama = SubResource("GradientTexture2D_yb0rj")
[sub_resource type="Sky" id="Sky_j6hso"]
sky_material = SubResource("ProceduralSkyMaterial_htlhh")
sky_material = SubResource("PanoramaSkyMaterial_c0cxy")
[sub_resource type="Environment" id="Environment_302o8"]
background_mode = 2
@ -77,10 +85,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17, 0, 5)
environment = SubResource("Environment_302o8")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -0.337161, 0.941447, 0, -0.941447, -0.337161, 0, 2.08989, 0)
transform = Transform3D(1, 0, 0, 0, -0.249636, 0.96834, 0, -0.96834, -0.249636, 0, 7.44648, 0)
[node name="Player" parent="." instance=ExtResource("3_5378m")]
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 0, 4.89631, 0)
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 4.896, 2.08165e-12)
[node name="CropTiles" type="Node3D" parent="."]
@ -98,4 +106,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8)
debug_growth = true
debug_growth_offset = 0.6
[node name="CropTile4" parent="CropTiles" instance=ExtResource("8_4ooup")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, -2)
debug_growth = true
debug_growth_offset = 0.6
[node name="Produce" type="Node3D" parent="."]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=5 format=3 uid="uid://bufi0wh54u5x5"]
[gd_scene load_steps=4 format=3 uid="uid://bufi0wh54u5x5"]
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="1_mkxnc"]
[ext_resource type="Script" path="res://menu/Menu.gd" id="2_6amk3"]

View file

@ -6,6 +6,7 @@ var last_fired := 0
var remaining := 10
@onready var ray = $RayCast3D
var croptile = preload("res://island/CropTile.tscn")
func _init() -> void:
@ -37,6 +38,7 @@ func shoot() -> void:
var normal = ray.get_collision_normal() as Vector3
var point = ray.get_collision_point() as Vector3
var object = ray.get_collider() as Node3D
try_placing_seed(ray)
# decalInstance.position = point
# object.add_child(decalInstance)
else:
@ -44,3 +46,21 @@ func shoot() -> void:
pass
remaining -= 1
func try_placing_seed(ray: RayCast3D) -> bool:
var point = ray.get_collision_point() as Vector3
var normal = ray.get_collision_normal() as Vector3
var obj = ray.get_collider() as Node3D
print(point, normal, obj.name)
if normal != Vector3(0,1,0):
print("Not horizontal, no plant for you :<")
return false
var correct_point = point.floor()
var crop = croptile.instantiate() as CropTile
crop.position = correct_point
crop.debug_growth = true
get_tree().root.add_child(crop)
return true

View file

@ -14,6 +14,11 @@ _global_script_classes=[{
"language": &"GDScript",
"path": "res://player/onhand/BaseWeapon.gd"
}, {
"base": "Node3D",
"class": &"CropTile",
"language": &"GDScript",
"path": "res://island/CropTile.gd"
}, {
"base": "BaseWeapon",
"class": &"PeaShooter",
"language": &"GDScript",
@ -31,6 +36,7 @@ _global_script_classes=[{
}]
_global_script_class_icons={
"BaseWeapon": "",
"CropTile": "",
"PeaShooter": "",
"Player": "",
"PlayerInputData": ""