Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        private void Start()
        {
            this.currentState = State.Idle;
            int layerIndex = this.anim.GetLayerIndex(this.animatorLayer);

            this.mapper = new AnimationStateMapper <State>(
                new List <string> {
                this.animatorLayer + ".Idle",
                this.animatorLayer + ".Aim",
                this.animatorLayer + ".Shoot"
            },
                this.anim,
                layerIndex);

            this.animOverride   = new AnimationOverrideHandler(this.anim);
            this.aimDir         = Vector2.zero;
            this.mousePos       = Vector2.zero;
            this.currentClipSet = 0;
            this.aimHash        = Animator.StringToHash("Aim");
            this.shootHash      = Animator.StringToHash("Shoot");
            this.sceneCamera    = FindObjectOfType <Camera>();
        }