// Start is called before the first frame update void Start() { this.transform.position = GlobalVariables.spawnPos; GlobalVariables.globalObjects["player"] = this.gameObject; controller = this.gameObject.GetComponent <CharacterMoverComponent>(); meleeAttack = this.gameObject.GetComponent <CharacterMeleeComponent>(); hud = this.gameObject.GetComponent <PlayerHUDComponent>(); vfx = this.gameObject.GetComponent <PlayerVFXComponent>(); level = this.gameObject.GetComponent <CharacterLevelComponent>(); animator = this.gameObject.GetComponent <Animator>(); animator.SetFloat("AnimSpeed", 1.0f); rangedAttack = GetComponent <CharacterRangedComponent>(); health = GetComponent <CharacterHealthComponent>(); health.health = PlayerStats.Health; health.maxHealth = PlayerStats.Maxhealth; hud.hasKey = PlayerStats.HasKey; hud.hasNecklace = PlayerStats.HasNecklace; level.XP = PlayerStats.Xp; level.level = PlayerStats.Level; level.levelUp = PlayerStats.Levelup; hud.hasSword = PlayerStats.HasSword; }
private void Start() { player = GameObject.Find("Player"); hud = player.GetComponent <PlayerHUDComponent>(); health = player.GetComponent <CharacterHealthComponent>(); level = player.GetComponent <CharacterLevelComponent>(); }
private void OnCollisionEnter2D(Collision2D other) { HUD = other.collider.GetComponent <PlayerHUDComponent>(); if (HUD != null && HUD.hasKey) { Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { PlayerHUDComponent HUD = other.GetComponent <PlayerHUDComponent>(); if (HUD == null) { return; } HUD.getNecklace(); Destroy(gameObject); }
void Start() { Object cache; GlobalVariables.globalObjects.TryGetValue("player", out cache); if (cache != null) { player = (GameObject)cache; } HUD = player.GetComponent <PlayerHUDComponent>(); }