Browse Source

[Hero 5] Add portal placement and portal behavior

master
Luna 7 years ago
parent
commit
1fdff52429
9 changed files with 253 additions and 1 deletions
  1. BIN
      assets/heroes/5_portal.blend
  2. +58
    -0
      assets/heroes/5_portal.obj
  3. +6
    -0
      project.godot
  4. +10
    -0
      scenes/heroes/5.tscn
  5. +97
    -0
      scenes/heroes/5_portal.tscn
  6. +0
    -1
      scenes/level.tscn
  7. +2
    -0
      scripts/hero_select.gd
  8. +25
    -0
      scripts/heroes/5.gd
  9. +55
    -0
      scripts/heroes/5_portal.gd

BIN
assets/heroes/5_portal.blend View File


+ 58
- 0
assets/heroes/5_portal.obj View File

@ -0,0 +1,58 @@
# Blender v2.79 (sub 0) OBJ File: '5_portal.blend'
# www.blender.org
o Cube.001
v 0.753035 -0.006579 0.750628
v 0.753035 0.417610 0.750628
v -0.746965 -0.006579 0.750628
v -0.746965 0.417610 0.750628
v 0.753035 -0.006579 -0.749372
v 0.753035 0.417610 -0.749372
v -0.746965 -0.006579 -0.749372
v -0.746965 0.417610 -0.749372
v 0.541430 0.417610 0.539022
v 0.541430 -0.006579 0.539022
v 0.541430 0.417610 -0.537767
v 0.541430 -0.006579 -0.537767
v -0.535359 0.417610 0.539022
v -0.535359 -0.006579 0.539022
v -0.535359 0.417610 -0.537767
v -0.535359 -0.006579 -0.537767
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
s off
f 2//1 3//1 1//1
f 4//2 7//2 3//2
f 8//3 5//3 7//3
f 6//4 1//4 5//4
f 7//5 12//5 16//5
f 11//6 2//6 6//6
f 11//1 16//1 12//1
f 15//4 14//4 16//4
f 13//6 8//6 4//6
f 13//3 10//3 14//3
f 9//2 12//2 10//2
f 10//5 5//5 1//5
f 2//1 4//1 3//1
f 4//2 8//2 7//2
f 8//3 6//3 5//3
f 6//4 2//4 1//4
f 14//5 3//5 7//5
f 7//5 5//5 12//5
f 16//5 14//5 7//5
f 6//6 8//6 15//6
f 11//6 9//6 2//6
f 6//6 15//6 11//6
f 11//1 15//1 16//1
f 15//4 13//4 14//4
f 4//6 2//6 9//6
f 13//6 15//6 8//6
f 4//6 9//6 13//6
f 13//3 9//3 10//3
f 9//2 11//2 12//2
f 3//5 14//5 10//5
f 10//5 12//5 5//5
f 1//5 3//5 10//5

+ 6
- 0
project.godot View File

@ -42,6 +42,12 @@ hero_3_unmerge=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_
]
hero_4_stun=[ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
]
hero_5_place_portal=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":46,"unicode":0,"echo":false,"script":null)
]
hero_5_confirm_portal=[ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
]
hero_5_remove_portal=[ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
]
[rendering]


+ 10
- 0
scenes/heroes/5.tscn View File

@ -0,0 +1,10 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/heroes/5.gd" type="Script" id=2]
[node name="RigidBody" instance=ExtResource( 1 )]
script = ExtResource( 2 )

+ 97
- 0
scenes/heroes/5_portal.tscn View File

@ -0,0 +1,97 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scripts/heroes/5_portal.gd" type="Script" id=1]
[ext_resource path="res://assets/heroes/5_portal.obj" type="ArrayMesh" id=2]
[sub_resource type="SpatialMaterial" id=1]
render_priority = 0
flags_transparent = false
flags_unshaded = false
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 0
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 1, 1, 1, 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
[sub_resource type="ConvexPolygonShape" id=2]
points = PoolVector3Array( -0.746582, -0.00657654, 0.750488, 0.75293, 0.41748, 0.750488, 0.75293, -0.00657654, 0.750488, -0.746582, -0.00657654, -0.749023, -0.746582, 0.41748, 0.750488, -0.746582, -0.00657654, 0.750488, 0.75293, -0.00657654, -0.749023, -0.746582, 0.41748, -0.749023, -0.746582, -0.00657654, -0.749023, 0.75293, -0.00657654, 0.750488, 0.75293, 0.41748, -0.749023, 0.75293, -0.00657654, -0.749023, 0.541016, -0.00657654, -0.537598, -0.746582, -0.00657654, -0.749023, -0.535156, -0.00657654, -0.537598, 0.75293, 0.41748, 0.750488, 0.541016, 0.41748, -0.537598, 0.75293, 0.41748, -0.749023, -0.535156, -0.00657654, -0.537598, 0.541016, 0.41748, -0.537598, 0.541016, -0.00657654, -0.537598, -0.535156, -0.00657654, 0.538574, -0.535156, 0.41748, -0.537598, -0.535156, -0.00657654, -0.537598, -0.746582, 0.41748, -0.749023, -0.535156, 0.41748, 0.538574, -0.746582, 0.41748, 0.750488, 0.541016, -0.00657654, 0.538574, -0.535156, 0.41748, 0.538574, -0.535156, -0.00657654, 0.538574, 0.541016, -0.00657654, -0.537598, 0.541016, 0.41748, 0.538574, 0.541016, -0.00657654, 0.538574, 0.75293, -0.00657654, -0.749023, 0.541016, -0.00657654, 0.538574, 0.75293, -0.00657654, 0.750488, -0.746582, 0.41748, 0.750488, -0.746582, 0.41748, -0.749023, 0.75293, 0.41748, -0.749023, 0.75293, 0.41748, 0.750488, -0.746582, -0.00657654, 0.750488, -0.535156, -0.00657654, 0.538574, -0.535156, 0.41748, -0.537598, 0.541016, 0.41748, 0.538574, -0.535156, 0.41748, -0.537598, -0.535156, 0.41748, 0.538574, 0.541016, 0.41748, 0.538574, 0.541016, 0.41748, -0.537598 )
[node name="StaticBody" type="StaticBody" index="0"]
input_ray_pickable = true
input_capture_on_drag = false
collision_layer = 1
collision_mask = 2
friction = 1.0
bounce = 0.0
constant_linear_velocity = Vector3( 0, 0, 0 )
constant_angular_velocity = Vector3( 0, 0, 0 )
script = ExtResource( 1 )
_sections_unfolded = [ "Collision" ]
[node name="MeshInstance" type="MeshInstance" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 )
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = ExtResource( 2 )
skeleton = NodePath("..")
material/0 = SubResource( 1 )
_sections_unfolded = [ "Transform", "Visibility" ]
[node name="CollisionShape" type="CollisionShape" parent="." index="1"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 )
shape = SubResource( 2 )
disabled = true

+ 0
- 1
scenes/level.tscn View File

@ -158,7 +158,6 @@ directional_shadow_max_distance = 200.0
[node name="Players" type="Spatial" parent="." index="1"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 11.4634, 0 )
_sections_unfolded = [ "Transform", "Visibility" ]
[node name="Ball" type="RigidBody" parent="." index="2"]


+ 2
- 0
scripts/hero_select.gd View File

@ -6,6 +6,7 @@ const hero_names = [
"LUSSURIA",
"CARITAS",
"PAZIENZA",
"SUPERBIA",
]
const hero_text = [
@ -14,6 +15,7 @@ const hero_text = [
"LUST.\n\nYou attract nearby heroes.\n\nPress E to switch to repelling them.",
"GENEROSITY.\n\nMake contact with a friend to boost their speed.\n\nPress E to separate.",
"PATIENCE.\n\nHold left mouse button on an enemy to slow them down.",
"PRIDE.\n\nBuild portals and shit. TODO: Instructions.",
]
func _ready():


+ 25
- 0
scripts/heroes/5.gd View File

@ -0,0 +1,25 @@
extends "res://scripts/player.gd"
onready var placement = preload("res://scripts/placement.gd").new(self, "res://scenes/heroes/5_portal.tscn")
# --- Godot overrides ---
func _ready():
placement.start_action = "hero_5_place_portal"
placement.confirm_action = "hero_5_confirm_portal"
placement.delete_action = "hero_5_remove_portal"
placement.max_placed = 100
func _process(delta):
if is_network_master():
placement.place_input()
func _exit_tree():
._exit_tree()
if placement:
placement.clear()
# --- Player overrides ---
# --- Own ---

+ 55
- 0
scripts/heroes/5_portal.gd View File

@ -0,0 +1,55 @@
extends "res://scripts/placeable.gd"
var portal_charge = 15
var other
var index
var first_color = Color("#d14013")
var second_color = Color("#ecb521")
func _ready():
for player in get_node("/root/Level/Players").get_children():
player.connect("body_entered", self, "player_collided", [player])
func init(maker):
var maker_portals = maker.placement.placed
index = maker_portals.size() # No -1, because we haven't actually been added to the array yet
# If index is odd, we're the second (1, 3...), if even, first (0, 4...)
var second = index % 2 != 0
var color = second_color if second else first_color
var mat = SpatialMaterial.new()
color.a = 0.5
mat.flags_transparent = true
mat.albedo_color = color
get_node("MeshInstance").set_surface_material(0, mat)
.init(maker)
func player_collided(with, player):
if with == self:
portal(player)
func find_other():
var maker_portals = maker_node.placement.placed
var count = maker_portals.size()
# If index is odd, we're the second (1, 3...), if even, first (0, 4...)
var second = index % 2 != 0
var delta = -1 if second else 1
if index + delta < count:
other = maker_portals[index + delta] # Second-to-last: we're already included
return other
else:
return null
func portal(player):
if find_other():
var spawn_distance = 2
# Find a sane place to spawn
# -Z is in the direction of the portal
# X is enough away from the portal to avoid infinite loop
# With both axes, gravity could never bring us to hit the portal
var to = other.to_global(Vector3(spawn_distance,0,-spawn_distance))
player.set_translation(to)

Loading…
Cancel
Save