void Awake() { character = GetComponent <PlayerCharacter>(); character_item = GetComponent <CharacterHoldItem>(); animator = GetComponent <Animator>(); character.onJump += OnJump; character.onCrouch += OnCrouch; }
void Awake() { character = GetComponent <PlayerCharacter>(); character_item = GetComponent <CharacterHoldItem>(); render = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); character.onJump += OnJump; character.onCrouch += OnCrouch; character.onHit += OnDamage; character.onDeath += OnDeath; character.onClimb += OnClimb; }
public void Take(CharacterHoldItem bearer) { this.bearer = bearer; last_bearer = bearer; collide.isTrigger = true; sprite_render.sortingLayerID = bearer.GetComponent <SpriteRenderer>().sortingLayerID; transform.localScale = start_size * carry_size; if (OnTake != null) { OnTake.Invoke(bearer.gameObject); } UpdateCarryItem(); }
public bool CanTake(GameObject taker) { CharacterHoldItem player = taker.GetComponent <CharacterHoldItem>(); CarryItem current_item = player.GetHeldItem(); if (current_item != null && item_type == current_item.item_type) { return(false); } if (take_timer >= -0.01f) { //Avoid taking back an item you just threw return(!throwing || last_bearer != taker); } return(false); }
public void Drop() { last_bearer = this.bearer; this.bearer = null; collide.isTrigger = throwing ? false : trigger_at_start; take_timer = -0.01f; if (last_bearer && !throwing) { //Reset straight floor position transform.position = new Vector3(last_bearer.transform.position.x, last_bearer.transform.position.y, initial_pos.z); transform.localScale = start_size; transform.rotation = start_rot; flipX = 1f; } if (OnDrop != null) { OnDrop.Invoke(last_bearer.gameObject); } }