private void Awake() { m_t = transform; m_current = this; m_camera = GetComponent <Camera>(); m_moving = false; m_audioListener = this.GetComponentDefault <AudioListener>(); m_audioListener.enabled = true; m_z = m_t.position.z; m_fov = m_camera.fieldOfView; m_camera.cullingMask |= Layers.MASK_DARK_MASK; #if UNITY_EDITOR if (!Game.started) { offset = m_t.position; euler = m_t.eulerAngles; } else #endif m_creature = Module_Battle.instance.current; if (m_creature) { return; } m_creature = null; EventManager.AddEventListener(CreatureEvents.PLAYER_ADD_TO_SCENE, OnPlayerAddToScene); }
private void UpdateShakeEffects() { if (m_curShakeIdx >= effectInfo.cameraShakes.Length) { return; } var shake = effectInfo.cameraShakes[m_curShakeIdx]; if (m_time < shake.startFrame) { return; } ++m_curShakeIdx; var shakeInfo = ConfigManager.Get <CameraShakeInfo>(shake.intValue0); if (shakeInfo) { Camera_Combat.Shake(shakeInfo.intensity, shakeInfo.duration * 0.001f, shakeInfo.range, position, source); } UpdateShakeEffects(); }
private void ClearSpecialStates() { var c = stateMachine.creature; c.RemoveToughState(m_toughs); m_toughs.Clear(); if (invincibleCount > 0) { c.invincibleCount -= invincibleCount; } if (weakCount > 0) { c.weakCount -= weakCount; } if (etherealCount > 0) { c.etherealCount -= etherealCount; } if (passiveEtherealCount > 0) { c.passiveEtherealCount -= passiveEtherealCount; } if (rimCount > 0) { c.rimCount -= rimCount; } if (hideHpSliderCount > 0) { c.hpVisiableCount += hideHpSliderCount; } if (darkCount > 0) { Camera_Combat.Dark(-darkCount, 0); } ClearSourcePassive(stateMachine.passiveSource); stateMachine.SetParam(StateMachineParam.prevEthreal, etherealCount); stateMachine.SetParam(StateMachineParam.prevPassiveEthreal, passiveEtherealCount); hideHpSliderCount = 0; invincibleCount = 0; weakCount = 0; etherealCount = 0; passiveEtherealCount = 0; rimCount = 0; darkCount = 0; fatal = false; m_holdRimCount = 0; m_rimLight = true; }
private void OnDestroy() { m_creature = null; m_fading = false; follow = null; lockZ = false; if (canDestroyCurrent) { m_current = null; } EventManager.RemoveEventListener(this); }
private void LateUpdate() { if (updateInput) { m_keyState.Clear(); m_axisState.Clear(); m_mouseState.Clear(); SetInputState(); ParseInput(Time.smoothDeltaTime, Time.timeScale); } if (m_camera && Camera_Combat.current && Camera_Combat.current.transform != m_t) { Camera_Combat.ForceMaskRepaint(m_camera, Layers.INVISIBLE); } }
private void HandleFrameEvent() { var creature = stateMachine.creature; if (m_currentFrame == info.processes.x) { stateMachine.SetParam(StateMachineParam.exit, true); stateMachine.SetParam(StateMachineParam.process, 1); } if (m_currentFrame == info.processes.y) { m_waitToResetKey = true; // Clear key input next update } if (info.ignoreInput.y > 0 && info.ignoreInput.x != info.ignoreInput.y) { if (m_currentFrame == info.ignoreInput.x) { m_acceptInput = false; } else if (m_currentFrame == info.ignoreInput.y) { m_acceptInput = true; } } if (m_currentFrame == info.landingFrame && !creature.onGround) { m_falling = true; if (m_motionIndex > 1) { var velocity = (m_motion.points[m_motionIndex] - m_motion.points[m_motionIndex - 1]) * 0.3; if (velocity.magnitude == 0) { velocity = defaultFallSpeed; } else { velocity = new Vector3_(!stateMachine.creature.isForward ? -velocity.z : velocity.z, velocity.y >= 0 ? defaultFallSpeed.y : velocity.y, -velocity.x); } #region Debug log #if DEVELOPMENT_BUILD || UNITY_EDITOR if (velocity.z != 0) { Logger.LogError("<color=#00DDFF><b>[{6}:{5}]</b></color>, state <color=#00DDFF><b>[{0}:{1}]</b></color> has invalid landing frame <color=#00DDFF><b>[{2}]</b></color>, fallSpeed has Z velocity <color=#00DDFF><b>[{3}]</b></color>, motion ID: <color=#00DDFF><b>[{4}]</b></color>, last frame: <color=#00DDFF><b>[{7}]</b></color>", ID, name, info.landingFrame, velocity.z, m_motion.ID, parent.ID, parent.GetType(), m_motion.points[m_motionIndex - 1]); } #endif #endregion velocity.z = 0; // @TODO: Fix velocity validation fallSpeed = velocity; } } if (m_curSectionIdx < info.sections.Length && info.sections[m_curSectionIdx].startFrame == m_currentFrame) { creature.behaviour.attackCollider.SetAttackBox(info.sections[m_curSectionIdx].attackBox, stateMachine.GetHitEffect(off), creature.isForward); ++m_curSectionIdx; stateMachine.SetParam(StateMachineParam.section, m_curSectionIdx); } if (m_curInvisibleIndex < info.invisibles.Length && info.invisibles[m_curInvisibleIndex].startFrame == m_currentFrame) { var invisible = info.invisibles[m_curInvisibleIndex].disable; creature.SetLayer(invisible ? Layers.INVISIBLE : -1, invisible); ++m_curInvisibleIndex; } if (m_curWeakIndex < info.weaks.Length && info.weaks[m_curWeakIndex].startFrame == m_currentFrame) { if (info.weaks[m_curWeakIndex].disable) { creature.weakCount++; weakCount++; } else if (weakCount > 0) { creature.weakCount--; weakCount--; } ++m_curWeakIndex; } if (m_curToughIdx < info.toughs.Length && info.toughs[m_curToughIdx].startFrame == m_currentFrame) { var idx = m_toughs.Count - 1; if (idx > -1) { creature.RemoveToughState(m_toughs[idx]); m_toughs.RemoveAt(idx); UpdateRimLightState(-1); } var tlvl = info.toughs[m_curToughIdx].intValue0; if (tlvl > 0) { m_toughs.Add(creature.AddToughState(tlvl)); UpdateRimLightState(1); } ++m_curToughIdx; } if (info.invincible.y > 0) { if (m_currentFrame == info.invincible.x) { creature.invincibleCount++; invincibleCount++; UpdateRimLightState(1); } if (m_currentFrame == info.invincible.y + 1) { creature.invincibleCount--; invincibleCount--; UpdateRimLightState(-1); } } if (info.hideHpSlider.y > 0) { if (m_currentFrame == info.hideHpSlider.x) { hideHpSliderCount++; creature.hpVisiableCount--; } if (m_currentFrame == info.hideHpSlider.y + 1) { hideHpSliderCount--; creature.hpVisiableCount++; } } if (info.ethereal.y > 0) { if (m_currentFrame == info.ethereal.x) { creature.etherealCount++; etherealCount++; } if (m_currentFrame == info.ethereal.y + 1) { creature.etherealCount--; etherealCount--; } } if (info.passiveEthereal.y > 0) { if (m_currentFrame == info.passiveEthereal.x) { creature.passiveEtherealCount++; passiveEtherealCount++; } if (m_currentFrame == info.passiveEthereal.y + 1) { creature.passiveEtherealCount--; passiveEtherealCount--; } } while (m_curBuffIndex < info.buffs.Length && info.buffs[m_curBuffIndex].startFrame == m_currentFrame) { var b = info.buffs[m_curBuffIndex]; if (b.doubleValue0 == 0 || Module_Battle.Range() < b.doubleValue0) { var pet = creature as PetCreature; if (pet && b.intValue0 <= 0) { var skill = pet.GetSkillByState(name); if (skill) { var count = skill.skillInfo.buffs.Length; for (int i = 0; i < count; i++) { Buff.Create(skill.skillInfo.buffs[i], creature, creature, 0, -1, pet.petInfo.AdditiveLevel); } } } else { Buff.Create(b.intValue0, creature, null, b.intValue1); } } ++m_curBuffIndex; } var effects = info.effects; while (m_curEffectIdx < effects.Length && effects[m_curEffectIdx].startFrame == m_currentFrame) { if (m_inheritEffectsFrame.Contains(m_curEffectIdx)) { ++m_curEffectIdx; continue; } if (!creature.isPlayer && effects[m_curEffectIdx].self) { ++m_curEffectIdx; continue; } var eff = creature.behaviour.effects.PlayEffect(effects[m_curEffectIdx]); if (eff) { eff.localTimeScale = animationSpeed; if (eff.name == "effect_ringring" && info.fatalRadius > 0) { eff.lifeTime = -1; eff.localScale = Vector3.one * (float)info.fatalRadius; } } if (effects[m_curEffectIdx].inherit) { m_inheritEffectsFrame.Add(m_curEffectIdx); m_inheritEffects.Add(eff); } ++m_curEffectIdx; } while (m_curFlyingEffectIdx < info.flyingEffects.Length && info.flyingEffects[m_curFlyingEffectIdx].startFrame == m_currentFrame) { creature.behaviour.effects.PlayEffect(info.flyingEffects[m_curFlyingEffectIdx], stateMachine.GetHitEffect(off)); ++m_curFlyingEffectIdx; } while (m_curSoundEffectIdx < info.soundEffects.Length && info.soundEffects[m_curSoundEffectIdx].startFrame == m_currentFrame) { var se = info.soundEffects[m_curSoundEffectIdx]; ++m_curSoundEffectIdx; if (se.isEmpty || !se.global && !creature.isPlayer || UnityEngine.Random.Range(0, 1.0f) > se.rate) { continue; } var s = se.SelectSound(creature.roleProto, creature.gender); if (!s.isEmpty) { if (!se.interrupt) { AudioManager.PlayAudio(s.sound, se.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, se.overrideType); } else { AudioManager.PlayAudio(s.sound, se.isVoice || s.isVoice ? AudioTypes.Voice : AudioTypes.Sound, false, se.overrideType, h => { if (h) { m_audios.Add(h.id); } }); } } } if (m_curDarkIndex < info.darkScreens.Length && info.darkScreens[m_curDarkIndex].startFrame == m_currentFrame) { var alpha = (float)info.darkScreens[m_curDarkIndex].doubleValue0; var draw = alpha > 0; darkCount += draw ? 1 : -1; Camera_Combat.Dark(draw ? 1 : -1, alpha); ++m_curDarkIndex; } if (m_curRimIndex < info.rimLights.Length && info.rimLights[m_curRimIndex].startFrame == m_currentFrame) { m_rimLight = !info.rimLights[m_curRimIndex].disable; UpdateRimLightState(); ++m_curRimIndex; } if (m_curShakeIdx < info.cameraShakes.Length && info.cameraShakes[m_curShakeIdx].startFrame == m_currentFrame) { var shake = ConfigManager.Get <CameraShakeInfo>(info.cameraShakes[m_curShakeIdx].intValue0); if (shake) { Camera_Combat.Shake(shake.intensity, shake.duration * 0.001f, shake.range, creature); } ++m_curShakeIdx; } if (m_curHideIdx < info.hideWeapons.Length && info.hideWeapons[m_curHideIdx].startFrame == m_currentFrame) { var hide = info.hideWeapons[m_curHideIdx].disable; creature.behaviour.SetWeaponVisibility(-1, !hide, false); ++m_curHideIdx; } if (m_curHideOffIdx < info.hideOffWeapons.Length && info.hideOffWeapons[m_curHideOffIdx].startFrame == m_currentFrame) { var hide = info.hideOffWeapons[m_curHideOffIdx].disable; creature.behaviour.SetWeaponVisibility(-1, m_showOffWeapon && !hide, true); ++m_curHideOffIdx; } if (m_curHidePetIdx < info.hidePets.Length && info.hidePets[m_curHidePetIdx].startFrame == m_currentFrame) { if (creature.pet) { var hidePet = info.hidePets[m_curHidePetIdx].disable; creature.pet.enabledAndVisible = !hidePet; } ++m_curHidePetIdx; } if (m_curActorIdx < info.sceneActors.Length && info.sceneActors[m_curActorIdx].frame == m_currentFrame) { var a = info.sceneActors[m_curActorIdx]; var actor = (Level.current as Level_Battle)?.CreateSceneActor( a.actorID, creature.position_ + a.offset * (creature.direction == CreatureDirection.FORWARD ? 1 :-1), creature.direction, a.groupID, a.level); ++m_curActorIdx; if (actor == null) { return; } actor.SetCreatureCamp(creature.creatureCamp); BuffContext c = new BuffContext { id = 444, level = 1, owner = actor, delay = a.lifeTime }; Buff.Create(c); } }