public void HeroHit(int heroIndex, IBlock block) { if (block != null) { HeroDamageRunner orCreateHeroDamageRunner = Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroDamageRunner(heroIndex); BigDouble damage = orCreateHeroDamageRunner.RequestHeroDamage(); Singleton <ChunkRunner> .Instance.CauseAoeDamage(damage, block.Position(), 1f); } }
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 void PostInit() { SceneLoader root = SceneLoader.Instance; BindingManager bind = BindingManager.Instance; (from order in Singleton <PrestigeRunner> .Instance.PrestigeTriggered where order == PrestigeOrder.PrestigePost select order).Do(delegate { }).Subscribe(delegate { ResetChunks(); SpawnBaseCamp(); }).AddTo(root); BlocksClearTriggered.Do(delegate { }).Subscribe(delegate { if (!IsNextChunkBoss(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index)) { SpawnChunkIncrease(); } else if (PlayerData.Instance.BossFailedLastTime.Value) { SpawnChunkRetry(); } else { SpawnBoss(); } }).AddTo(root); (from _ in Singleton <BossSuccessRunner> .Instance.SequenceClosed where !ShouldGoToMap(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index, PlayerData.Instance.LifetimeChunk.Value) select _).Do(delegate { }).Subscribe(delegate { SpawnChunkIncrease(); }).AddTo(root); (from _ in Singleton <BossSuccessRunner> .Instance.SequenceClosed where ShouldGoToMap(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index, PlayerData.Instance.LifetimeChunk.Value) select _).Do(delegate { }).Subscribe(delegate { root.StartCoroutine(MapSequenceRoutine()); }).AddTo(root); (from win in Singleton <BossBattleRunner> .Instance.BossBattleResult.Skip(1) where !win select win).Delay(TimeSpan.FromSeconds(3.0)).Subscribe(delegate { if (PlayerData.Instance.BossFailedLastTime.Value) { SpawnChunkRetry(); } }).AddTo(root); (from tuple in Singleton <BossBattleRunner> .Instance.BossBattleActive.CombineLatest(Singleton <BossBattleRunner> .Instance.BossCurrentHP, (bool active, BigDouble hp) => new { active, hp }) where tuple.active select tuple).Subscribe(tuple => { ChunkMaxHealth.Value = Singleton <BossBattleRunner> .Instance.BossFullHP.Value; CurrentChunkHealth.Value = tuple.hp; }).AddTo(root); (from active in Singleton <BossBattleRunner> .Instance.BossBattleActive.Pairwise() where !active.Current && active.Previous select active).Subscribe(delegate { CurrentChunkHealth.Value = BigDouble.ZERO; }).AddTo(root); BlocksClearTriggered.Subscribe(delegate { CurrentChunkHealth.Value = BigDouble.ZERO; }).AddTo(root); (from _ in (from _ in TryBossAgainTriggered select(from moving in Singleton <CameraMoveRunner> .Instance.IsCameraMoving where !moving select moving).Take(1)).Switch() where !Singleton <BossBattleRunner> .Instance.BossLevelActive.Value select _).Subscribe(delegate { SpawnBossRetry(); }).AddTo(root); if (Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index == 0) { SpawnBaseCamp(); } else { SpawnGameLoaded(); } if (PlayerData.Instance.LifetimeChunk.Value == 0 && PersistentSingleton <GameSettings> .Instance.IntroSequenceOn) { BindingManager.Instance.MapPanel.SetActive(value: true); BindingManager.Instance.MapCamera.IntroCameraDrive(); } Singleton <TntRunner> .Instance.TntTriggered.Subscribe(delegate(BigDouble damage) { CauseDamageToRandomBlocks(damage, (128L * Singleton <CumulativeBonusRunner> .Instance.BonusMult[12].Value).ToInt()); Vector3 position = bind.CameraCtrl.transform.position; CauseBlastWave(position.x0z(), 10f); }).AddTo(root); HeroDamageRunner mainHeroDamage = Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroDamageRunner(0); Singleton <AutoMineRunner> .Instance.DamageTriggered.Subscribe(delegate { CauseDamageToClosestBlockOrBoss(mainHeroDamage.Damage.Value *PersistentSingleton <GameSettings> .Instance.AutoMineMultiplier, bind.TornadoDamageNode.position); }).AddTo(root); GoldBlockReward = BlocksInChunk.CombineLatest(Singleton <WorldRunner> .Instance.CurrentBiomeConfig, Singleton <GoldFingerRunner> .Instance.GoldFingerActive, GoldBlocks, (int blocks, BiomeConfig cnfg, bool goldFinger, int golds) => (!goldFinger) ? (new BigDouble(blocks) * cnfg.BlockReward / golds) : (cnfg.BlockReward * 13.5)).TakeUntilDestroy(root).ToReactiveProperty(); (from gf in Singleton <GoldFingerRunner> .Instance.GoldFingerActive.Pairwise() where !gf.Current && gf.Previous select gf).Subscribe(delegate { GoldBlockReward.SetValueAndForceNotify(Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value.BlockReward * 13.5); }).AddTo(root); CanBeHurt = Singleton <BossBattleRunner> .Instance.BossBattlePaused.CombineLatest(Singleton <PrestigeRunner> .Instance.SequenceDone, Singleton <WorldRunner> .Instance.MapSequence, (bool bossPause, bool prestigeDone, bool map) => !bossPause && prestigeDone && !map).TakeUntilDestroy(root).ToReadOnlyReactiveProperty(); TickerService.MasterTicksFast.Subscribe(delegate(long ticks) { m_timeSinceLastHitSound += ticks; m_timeSinceLastDestroySound += ticks; }).AddTo(root); (from triggered in BlocksClearTriggered where triggered select triggered).Subscribe(delegate { overflowChunk = false; }).AddTo(root); }