public static TrackAbstract GetInstance() { if (instance == null) { instance = FindObjectOfType(typeof(TrackAbstract)) as TrackAbstract; } return(instance); }
protected BaseState(Controller controller) { BaseState.controller = controller; BaseState.controllerTransform = controller.transform; track = Track3.GetInstance(); controllerCollider = controller.GetComponent <CharacterController>(); XRaycastLenght = Integrate(controller.ControllerParams.TurningCurve, 0f, 1f); turningIgnoreMask = ~((1 << controller.gameObject.layer) | (1 << 2)); isGroundIgnoreMask = ~(1 << LayerMask.NameToLayer("IgnoreForIsGround")); }
private void Start() { _animation = GetComponent <Animation>(); if (!_animation) { Debug.Log( "The character you would like to control doesn't have animations. Moving her might look weird."); } else { _animation[Animations.Run.name].speed = ControllerParams.RunAnimationSpeed; _animation[Animations.TurnToRight.name].speed = ControllerParams.TurningAnimationSpeed; _animation[Animations.TurnToLeft.name].speed = ControllerParams.TurningAnimationSpeed; for (int i = 0; i < Animations.JumpDown.Length; i++) { _animation[Animations.JumpDown[i].name].speed = ControllerParams.JumpDownAnimationSpeed; } for (int i = 0; i < Animations.JumpDown.Length; i++) { _animation[Animations.JumpUp[i].name].speed = ControllerParams.JumpUpAnimationSpeed; } } track = TrackAbstract.GetInstance(); if (!track) { track = null; Debug.Log("No Track found. Character can`t move without Track"); } _transform = transform; characterController = GetComponent <CharacterController>(); instance = this; ControllerParams.JumpVerticalSpeed = Mathf.Sqrt(2 * ControllerParams.JumpHeight * ControllerParams.Gravity); ControllerColliderDeadHeight = characterController.center.y + characterController.height * 0.5f; runingState = new RuningState(this); turningState = new TurningState(this); jumpingState = new JumpingState(this); disallowedTurnState = new DisallowedTurningState(this); stramedState = new StameredState(this); deadState = new DeadState(this); shieldAttackState = new ShieldAttackState(this, ControllerParams.ShieldAttackTime); swordAttackState = new SwordAttackState(this, ControllerParams.SwordAttackTime); ropeRollingState = new RopeRollingState(this); colliderRelSaved = characterController.center; PrepareToReplay(); if (footFlares) { footFlares.maxBrightness = MaxFlireBrightness; footFlares.TurnOff(); } life = new Life(); }
protected virtual void Awake() { if (instance != null && instance != this) { Debug.LogWarning("One track is alredy exists. See " + instance.gameObject.name); DestroyImmediate(this); } else if (instance == null) { instance = this; } }
private void Start() { instance = this; controllerCollider = GetComponent <CharacterController>(); track = TrackAbstract.GetInstance(); }
private void OnApplicationQuit() { instance = null; }