public override void Init(int heroIndex, CreatureStateEnum defaultState) { Init(heroIndex); m_stateMachine = new AnimationStateMachine(9, m_animation); m_blockFinder = new MainHeroBlockFinder(this); m_damageRunner = Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroDamageRunner(0); m_raycastMask = 1 << LayerMask.NameToLayer("Blocks"); AnimState animState = new AnimState(0); animState.AnimationNames = new string[1] { "Enter" }; animState.Looping = false; animState.Speed.Set(0.9f, 1.1f); animState.Enter = delegate { m_blockFinder.Clear(); base.transform.position = GetEnterPosition(); m_stateMachine.Skeleton.FlipX = false; AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventEnter, AUDIOEVENTACTION.Play)); }; animState.AnimComplete = EnterComplete; m_stateMachine.Add(animState); AnimState animState2 = new AnimState(1); animState2.AnimationNames = new string[4] { "Idle1", "Idle2", "Idle3", "Idle4" }; animState2.Looping = true; animState2.Speed.Set(0.9f, 1.1f); animState2.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState2.Step = StepIdle; m_stateMachine.Add(animState2); AnimState animState3 = new AnimState(3); animState3.AnimationNames = new string[4] { "Idle1", "Idle2", "Idle3", "Idle4" }; animState3.Looping = true; animState3.Speed.Set(0.9f, 1.1f); animState3.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; m_stateMachine.Add(animState3); AnimState animState4 = new AnimState(2); animState4.AnimationNames = new string[1] { "Cheering" }; animState4.Looping = true; animState4.Speed.Set(0.9f, 1.1f); animState4.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventCheer, AUDIOEVENTACTION.Play)); }; animState4.Exit = delegate { AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventCheer, AUDIOEVENTACTION.Stop)); }; m_stateMachine.Add(animState4); AnimState animState5 = new AnimState(4); animState5.AnimationNames = new string[1] { "Move" }; animState5.Looping = true; animState5.Speed.Set(0.9f, 1.1f); animState5.Enter = delegate { Vector3 vector = GetWantedPosition() - base.transform.position; m_stateMachine.Skeleton.FlipX = (vector.x + vector.z * 0.5f < 0f); }; animState5.Step = StepMove; m_stateMachine.Add(animState5); AnimState animState6 = new AnimState(5); animState6.AnimationNames = new string[5] { "Attack1", "Attack2", "Attack3", "Attack4", "Attack5" }; animState6.Looping = true; animState6.Speed.Set(0.9f, 1.1f); animState6.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState6.AnimComplete = AttackComplete; animState6.AnimEvent = AttackEvent; animState6.Step = AttackStep; m_stateMachine.Add(animState6); AnimState animState7 = new AnimState(7); animState7.AnimationNames = new string[1] { "Attack6" }; animState7.Looping = true; animState7.Speed.Set(0.9f, 1.1f); animState7.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState7.AnimComplete = AttackComplete; animState7.AnimEvent = AttackEvent; m_stateMachine.Add(animState7); m_stateMachine.NextState = (int)defaultState; PlayerData.Instance.MainChunk.Subscribe(delegate { m_blockFinder.Clear(); }).AddTo(this); (from pair in Singleton <CameraMoveRunner> .Instance.IsCameraMoving.Pairwise() select pair.Previous&& !pair.Current into cameraStopped where cameraStopped select cameraStopped).Subscribe(delegate { m_stateMachine.NextState = 0; }).AddTo(this); Singleton <ChunkRunner> .Instance.BlocksClearTriggered.Subscribe(delegate { m_stateMachine.NextState = 3; }).AddTo(this); (from win in Singleton <BossBattleRunner> .Instance.BossBattleResult.Skip(1) where win select win).Subscribe(delegate { m_stateMachine.NextState = 2; }).AddTo(this); Singleton <ChunkRunner> .Instance.ChapterCompleted.Subscribe(delegate { m_stateMachine.NextState = 0; }).AddTo(this); (from active in Singleton <HammerTimeRunner> .Instance.Active.DelayFrame(1) select(!active) ? "Common" : "Gold").Subscribe(delegate(string skin) { m_animation.skeleton.SetSkin(skin); m_animation.skeleton.SetSlotsToSetupPose(); m_animation.AnimationState.Apply(m_animation.skeleton); }).AddTo(this); }
public override void Init(int heroIndex, CreatureStateEnum defaultState) { Init(heroIndex); m_stateMachine = new AnimationStateMachine(9, m_animation); m_blockFinder = new CreatureBlockFinder(this); m_projectileBone = m_stateMachine.Skeleton.FindBone("root"); AnimState animState = new AnimState(0); animState.AnimationNames = new string[1] { "Enter" }; animState.Looping = false; animState.Speed.Set(0.9f, 1.1f); animState.Enter = delegate { m_blockFinder.Clear(); base.transform.position = GetEnterPosition(); m_stateMachine.Skeleton.FlipX = false; AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventEnter, AUDIOEVENTACTION.Play)); }; animState.AnimComplete = EnterComplete; m_stateMachine.Add(animState); AnimState animState2 = new AnimState(1); animState2.AnimationNames = new string[1] { "Idle" }; animState2.Looping = true; animState2.Speed.Set(0.9f, 1.1f); animState2.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState2.Step = StepIdle; m_stateMachine.Add(animState2); AnimState animState3 = new AnimState(3); animState3.AnimationNames = new string[1] { "Idle" }; animState3.Looping = true; animState3.Speed.Set(0.9f, 1.1f); animState3.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; m_stateMachine.Add(animState3); AnimState animState4 = new AnimState(2); animState4.AnimationNames = new string[1] { "Cheering" }; animState4.Looping = true; animState4.Speed.Set(0.9f, 1.1f); animState4.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventCheer, AUDIOEVENTACTION.Play)); }; animState4.Exit = delegate { AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventCheer, AUDIOEVENTACTION.Stop)); }; m_stateMachine.Add(animState4); AnimState animState5 = new AnimState(4); animState5.AnimationNames = new string[1] { "Move" }; animState5.Looping = true; animState5.Speed.Set(1.53f, 1.87000012f); animState5.Enter = delegate { Vector3 vector = GetWantedPosition() - base.transform.position; m_stateMachine.Skeleton.FlipX = (vector.x + vector.z * 0.5f < 0f); }; animState5.Step = StepMove; m_stateMachine.Add(animState5); AnimState animState6 = new AnimState(5); animState6.AnimationNames = new string[1] { "Attack" }; animState6.Looping = true; animState6.Speed.Set(1.61999989f, 1.98f); animState6.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventAttack, AUDIOEVENTACTION.Play)); }; animState6.AnimComplete = AttackComplete; animState6.AnimEvent = AttackEvent; m_stateMachine.Add(animState6); AnimState animState7 = new AnimState(6); animState7.AnimationNames = new string[1] { "Captured" }; animState7.Looping = true; animState7.Enter = delegate { m_stateMachine.Skeleton.FlipX = true; AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventCaptured, AUDIOEVENTACTION.Play)); }; animState7.Exit = delegate { AudioController.Instance.QueueEvent(new AudioEvent(m_audioEventCaptured, AUDIOEVENTACTION.Stop)); }; m_stateMachine.Add(animState7); AnimState animState8 = new AnimState(8); animState8.AnimationNames = new string[4] { "Level0", "Level1", "Level2", "Level3" }; animState8.Looping = true; animState8.Enter = delegate { m_stateMachine.Skeleton.FlipX = true; }; m_stateMachine.Add(animState8); m_stateMachine.NextState = (int)defaultState; PlayerData.Instance.MainChunk.Subscribe(delegate { m_blockFinder.Clear(); }).AddTo(this); (from pair in Singleton <CameraMoveRunner> .Instance.IsCameraMoving.Pairwise() select pair.Previous&& !pair.Current into cameraStopped where cameraStopped select cameraStopped into _ where m_stateMachine.CurrentState != 6 select _).Subscribe(delegate { m_stateMachine.NextState = 0; }).AddTo(this); Singleton <ChunkRunner> .Instance.BlocksClearTriggered.Subscribe(delegate { m_stateMachine.NextState = 3; }).AddTo(this); (from win in Singleton <BossBattleRunner> .Instance.BossBattleResult where win select win).Subscribe(delegate { m_stateMachine.NextState = 2; }).AddTo(this); (from _ in Singleton <ChunkRunner> .Instance.ChapterCompleted where m_stateMachine.CurrentState != 6 select _).Subscribe(delegate { m_stateMachine.NextState = 0; }).AddTo(this); (from seq in Singleton <WorldRunner> .Instance.MapSequence.Pairwise() where !seq.Current && seq.Previous select seq).DelayFrame(1).Subscribe(delegate { m_stateMachine.NextState = 0; }).AddTo(this); Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroRunner(m_heroIndex).Tier.Subscribe(delegate(int tier) { m_stateMachine.PlayOverrideAnimOrdered(8, Mathf.Max(Mathf.Min(tier - 1, 3), 0)); }).AddTo(this); (from tier in Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroRunner(m_heroIndex).Tier select Mathf.Max(Mathf.Min(tier, 4), 1)).Subscribe(delegate(int evoLvl) { switch (evoLvl) { case 1: Speed = 15f; break; case 2: Speed = 30f; break; case 3: Speed = 50f; break; case 4: Speed = 80f; break; } }).AddTo(this); }
private void Init() { m_animation = GetComponentInChildren <SkeletonAnimation>(); m_stateMachine = new AnimationStateMachine(5, m_animation); AnimState animState = new AnimState(0); animState.AnimationNames = new string[1] { "DrJelly_Entry" }; animState.Looping = false; animState.Speed.Set(0.9f, 1.1f); animState.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState.MixDuration = 0f; animState.AnimComplete = EnterComplete; m_stateMachine.Add(animState); AnimState animState2 = new AnimState(1); animState2.AnimationNames = new string[1] { "DrJelly_Idle" }; animState2.Looping = true; animState2.Speed.Set(0.9f, 1.1f); animState2.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState2.MixDuration = 0.5f; m_stateMachine.Add(animState2); AnimState animState3 = new AnimState(2); animState3.AnimationNames = new string[1] { "DrJelly_Exit" }; animState3.Looping = false; animState3.Speed.Set(0.9f, 1.1f); animState3.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState3.MixDuration = 0.5f; m_stateMachine.Add(animState3); AnimState animState4 = new AnimState(3); animState4.AnimationNames = new string[1] { "_Shooting" }; animState4.Looping = false; animState4.Speed.Set(0.9f, 1.1f); animState4.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; animState4.AnimComplete = ShootingComplete; animState4.MixDuration = 0.5f; m_stateMachine.Add(animState4); AnimState animState5 = new AnimState(4); animState5.AnimationNames = new string[1] { "HitEffect" }; animState5.Looping = false; animState5.Speed.Set(0.9f, 1.1f); animState5.Enter = delegate { m_stateMachine.Skeleton.FlipX = false; }; m_stateMachine.Add(animState5); m_stateMachine.NextState = 0; Singleton <BossBattleRunner> .Instance.BossBattleResult.Skip(1).Subscribe(delegate { m_stateMachine.NextState = 2; }).AddTo(this); (from hp in Singleton <BossBattleRunner> .Instance.BossCurrentHP.ThrottleFirst(TimeSpan.FromSeconds(0.2)).Pairwise() where hp.Current < hp.Previous select hp).Subscribe(delegate { GetHit(); }).AddTo(this); }