private void Start() { this.anim = GetComponent <Animator>(); this.rgbdy = GetComponent <Rigidbody2D>(); this.input = GetComponent <HeroInput>(); this.stateMap = new StateMap(); this.doOnce = false; this.attackHash = Animator.StringToHash("Attack"); this.attackFinishedHash = Animator.StringToHash("AttackFinished"); this.hitHash = Animator.StringToHash("Hit"); this.Health = this.maxHealth; this.CurrentWeapon = 0; this.CurrentState = Enums.HeroState.Idle; if (HeroData.Instance.weaponLevels == null || HeroData.Instance.weaponLevels.Length == 0) { HeroData.Instance.weaponLevels = new int[this.weapons.Length]; for (int i = 0; i < this.weapons.Length; i++) { HeroData.Instance.weaponLevels[i] = 0; } } foreach (Weapon w in this.weapons) { w.Init(); w.CleanUp(); } this.weapons[this.CurrentWeapon].Level = HeroData.Instance.weaponLevels[this.CurrentWeapon]; }
private void Start() { if (this.anim == null) { this.anim = GetComponent <Animator>(); } this.animOverride = new AnimationOverrideHandler(this.anim); this.rgbdy = GetComponent <Rigidbody2D>(); this.input = GetComponent <HeroInput>(); this.stateMap = new StateMap <Enums.HeroState>(); this.doOnce = false; this.attackHash = Animator.StringToHash("Attack"); this.attackFinishedHash = Animator.StringToHash("AttackFinished"); this.hitHash = Animator.StringToHash("Hit"); this.Health = this.maxHealth; this.CurrentWeapon = 0; this.CurrentState = Enums.HeroState.Idle; this.crosshair = Instantiate(crosshair); this.currentClipSet = 0; this.deathParticles = GetComponentInChildren <ParticleSystem>(); this.isInvulnerable = false; this.isVisible = true; this.invunTimer = 0; this.flashTimer = 0; this.sprite.enabled = isVisible; // HACK: Addresses Unity bug where ParticleSystem.Emit() spawns particles // at the origin regardless of the particle system's position until a particle is emitted. this.deathParticles.Emit(1); Camera[] cameras = FindObjectsOfType <Camera>(); foreach (Camera c in cameras) { if (c.GetComponent <Effects.Shake>() != null) { this.cameraShake = c.GetComponent <Effects.Shake>(); } } if (HeroData.Instance.weaponLevels == null || HeroData.Instance.weaponLevels.Length == 0) { HeroData.Instance.weaponLevels = new int[this.weapons.Length]; for (int i = 0; i < this.weapons.Length; i++) { HeroData.Instance.weaponLevels[i] = 0; } } for (int i = 0; i < this.weapons.Length; i++) { this.weapons[i].Init(HeroData.Instance.weaponLevels[i]); this.weapons[i].CleanUp(); } this.squishing.StartSquishing(); }
private void Start() { this.anim = GetComponent <Animator>(); this.rgbdy = GetComponent <Rigidbody2D>(); this.input = GetComponent <HeroInput>(); this.stateMap = new StateMap(); this.doOnce = false; this.attackFinishedHash = Animator.StringToHash("AttackFinished"); this.hitHash = Animator.StringToHash("Hit"); this.Health = this.maxHealth; this.CurrentWeapon = 0; this.CurrentState = Enums.HeroState.Idle; foreach (Weapon w in this.weapons) { w.Init(); w.CleanUp(); } }