Browse Source

[Hero 1] Gain charge from being seen; add wall cost

If a player looks at you or a wall you built, you gain charge, and steal
it from them!

Then, building walls now costs 15 charge.
master
Luna 7 years ago
parent
commit
6337bbac1b
4 changed files with 47 additions and 2 deletions
  1. +17
    -1
      scenes/heroes/1.tscn
  2. +20
    -1
      scripts/heroes/1.gd
  3. +3
    -0
      scripts/heroes/1_wall.gd
  4. +7
    -0
      scripts/player.gd

+ 17
- 1
scenes/heroes/1.tscn View File

@ -1,9 +1,10 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=1]
[ext_resource path="res://scripts/heroes/1.gd" type="Script" id=2]
[ext_resource path="res://assets/heroes/1_head.obj" type="ArrayMesh" id=3]
[ext_resource path="res://assets/heroes/1.obj" type="ArrayMesh" id=4]
[ext_resource path="res://scenes/ability_icon.tscn" type="PackedScene" id=5]
[sub_resource type="CapsuleShape" id=1]
@ -13,6 +14,7 @@ height = 0.5
[node name="RigidBody" instance=ExtResource( 1 )]
script = ExtResource( 2 )
looked_at_charge_suck = 25
[node name="Body" parent="." index="0"]
@ -28,6 +30,20 @@ mesh = ExtResource( 3 )
transform = Transform( 1, 0, 0, 0, -1.54624e-07, -0.949072, 0, 1, -1.62921e-07, 0, 0.725089, 0 )
mesh = ExtResource( 4 )
[node name="PlaceWall" parent="MasterOnly" index="3" instance=ExtResource( 5 )]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -93.0
margin_top = -112.0
margin_right = -63.0
margin_bottom = -82.0
cost = 15
ability_name = "Place Wall"
action = "hero_1_place_wall"
[node name="TPCamera" parent="." index="5"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.17139, 0 )


+ 20
- 1
scripts/heroes/1.gd View File

@ -1,6 +1,9 @@
extends "res://scripts/player.gd"
onready var placement = preload("res://scripts/placement.gd").new(self, "res://scenes/heroes/1_wall.tscn")
onready var place_wall_ability = get_node("MasterOnly/PlaceWall")
export var looked_at_charge_suck = 25 # charge / sec
# --- Godot overrides ---
@ -12,7 +15,10 @@ func _ready():
func _process(delta):
if is_network_master():
placement.place_input()
var can_build = switch_charge > place_wall_ability.cost
if can_build:
if placement.place_input():
build_charge(-place_wall_ability.cost)
func _exit_tree():
._exit_tree()
@ -28,3 +34,16 @@ func spawn():
# --- Own ---
# Passive: suck the charge out of people who look at us!
# This is a special method called by player when any object is looked at
func on_looked_at(who, delta):
# Why do we check this if we can't look at ourselves? Walls call this method from their looked_at
# Also, why not use util.is_friendly? Because we're not master, we're slave (looker is master)
if who.player_info.is_right_team != player_info.is_right_team:
var subtracted = who.build_charge(-looked_at_charge_suck * delta)
build_charge(-subtracted)
# We rset our switch_charge because otherwise it won't be acknowledged
# because we're not master
# The *PICKER* is master, we're slave! Well, let's flip that for a mo'
rset("switch_charge", switch_charge)

+ 3
- 0
scripts/heroes/1_wall.gd View File

@ -34,3 +34,6 @@ func count_bodies(with, player, delta):
if player != maker_node:
being_touched += delta
func on_looked_at(who, delta):
maker_node.on_looked_at(who, delta)

+ 7
- 0
scripts/player.gd View File

@ -103,6 +103,13 @@ func _process(delta):
if "record" in player_info:
recording.time += delta
# on_looked_at is a special method for objects that need to respond to being looked at
# This was the best way to implement Hero 1's passive ability,
# But it'll probably come in handy more often so I made it kinda universal
var looking_at = pick()
if looking_at and looking_at.has_method("on_looked_at"):
looking_at.on_looked_at(self, delta)
func _integrate_forces(state):
if is_network_master():
control_player(state)


Loading…
Cancel
Save