internal void SetAllOff() { currentState = GlideState.Off; if (lastState != currentState) { SetRed(animLow, AminNameTooLow); SetRed(animRight, AnimNameRight); SetRed(animHigh, AnimNameHigh); SetRed(animTooHigh, AnimNameTooHigh); } lastState = currentState; }
/// <summary> /// 初期化処理 /// </summary> void Awake() { // 子オブジェクトを取得 feverEffect = transform.Find("FeverEffect").GetComponent <ParticleSystem>(); boostEffect = transform.Find("BoostEffect").GetComponent <ParticleSystem>(); chargeingEffect = transform.Find("ChargeEffects/Charging").GetComponent <ParticleSystem>(); chargeSignal = transform.Find("ChargeEffects/ChargeSignal").GetComponent <ParticleSystem>(); chargePauseEffect = transform.Find("ChargeEffects/ChargePause").GetComponent <ParticleSystem>(); chargeMaxEffect = transform.Find("ChargeEffects/ChargeMax").GetComponent <ParticleSystem>(); // アタッチされているステートを取得 aerialState = GetComponent <AerialState>(); afterSlideState = GetComponent <AfterSlideState>(); boostState = GetComponent <BoostState>(); downState = GetComponent <DownState>(); glideState = GetComponent <GlideState>(); idleState = GetComponent <IdleState>(); runState = GetComponent <RunState>(); slideState = GetComponent <SlideState>(); afterGoalState = GetComponent <AfterGoalState>(); // ステートを管理するクラスを取得 playerStateManager = new PlayerStateManager(); }
public void Update() { // dont do anything when its not in flight if (HighLogic.LoadedScene != GameScenes.FLIGHT) { SetAllOff(); return; } // hmm no vessel found.. thats bad because you are not flying... if (FlightGlobals.ActiveVessel == null) { SetAllOff(); return; } // the vessel is not active?!? we don't deal with such alien spacecraft. if (FlightGlobals.ActiveVessel.state != Vessel.State.ACTIVE) { SetAllOff(); return; } // Only deal with flying things. if (FlightGlobals.ActiveVessel.situation != Vessel.Situations.FLYING) { SetAllOff(); return; } // from here it should be save to do acually some things. touchDownPoint = staticInstance.gameObject.transform.position + (directionsMult * staticInstance.gameObject.transform.forward.normalized * touchDownOffset); vesselPosition = FlightGlobals.ActiveVessel.GetWorldPos3D(); fromVesseltoPoint = (touchDownPoint - FlightGlobals.ActiveVessel.GetWorldPos3D()); horizontalVector = Vector3.ProjectOnPlane(fromVesseltoPoint, staticInstance.gameObject.transform.up); if (Vector3d.Dot(horizontalVector, directionsMult * staticInstance.gameObject.transform.forward.normalized) < 0) { // we are behind the lights. no need to update them anymore. SetAllOff(); return; } currentDistance = horizontalVector.magnitude; // Do nothing if too far away if (currentDistance > maxDist) { SetAllOff(); return; } if (showDebug) { DebugDrawer.DebugVector(touchDownPoint, -horizontalVector, new Color(0.2f, 0.2f, 0.7f)); DebugDrawer.DebugLine(touchDownPoint, vesselPosition, new Color(0.2f, 0.7f, 0.2f)); } currentState = GetCurrentGlideState(); if (lastState != currentState) { //Log.Normal("PAPI: Switching State: " + lastState.ToString() + " to " + currentState.ToString()); lastState = currentState; switch (currentState) { case GlideState.TooHigh: if (animTooHigh != null) { SetWhite(animLow, AminNameTooLow); SetWhite(animRight, AnimNameRight); SetWhite(animHigh, AnimNameHigh); SetWhite(animTooHigh, AnimNameTooHigh); } break; case GlideState.High: if (animHigh != null) { SetWhite(animLow, AminNameTooLow); SetWhite(animRight, AnimNameRight); SetWhite(animHigh, AnimNameHigh); SetRed(animTooHigh, AnimNameTooHigh); } break; case GlideState.Right: if (animRight != null) { SetWhite(animLow, AminNameTooLow); SetWhite(animRight, AnimNameRight); SetRed(animHigh, AnimNameHigh); SetRed(animTooHigh, AnimNameTooHigh); } break; case GlideState.Low: if (animLow != null) { SetWhite(animLow, AminNameTooLow); SetRed(animRight, AnimNameRight); SetRed(animHigh, AnimNameHigh); SetRed(animTooHigh, AnimNameTooHigh); } break; case GlideState.TooLow: if (animLow != null) { SetRed(animLow, AminNameTooLow); SetRed(animRight, AnimNameRight); SetRed(animHigh, AnimNameHigh); SetRed(animTooHigh, AnimNameTooHigh); } break; } } }