/// <summary> /// Stand on a respawn point to activate it. You could play a particle effect of something here. /// </summary> override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN) { currentRespawnPoint = this; } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { // If we are standing on this if (!alreadyAdded && collider.direction == RC_Direction.DOWN) { character.SetDrag(drag); alreadyAdded = true; } }
public override void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN) { characterIsOnMe = true; standTimer = standTime; } }
public override void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN && !fallStarted) { fallStarted = true; StartCoroutine(Fall()); } }
void Start() { if (controller == null) { controller = GetComponent <RaycastCharacterController>(); } }
/// <summary> /// Call to recalculate the direction. /// </summary> /// <returns><c>true</c>, if colliders were switched, <c>false</c> otherwise.</returns> virtual public bool UpdateDirection (RaycastCharacterController character) { int newDirection = 0; // Always return ledge hang dir - NEW if (character.IsLedgeHanging) { if (character.LedgeHangDirection == RC_Direction.RIGHT) newDirection = 1; if (character.LedgeHangDirection == RC_Direction.LEFT) newDirection = -1; } if (character.characterInput.x > 0.0f) newDirection = 1; if (character.characterInput.x < 0.0f) newDirection = -1; //if (character.Velocity.x > 0.0f) newDirection = 1; //if (character.Velocity.x < 0.0f) newDirection = -1; // If PULLING then return oppoiste direction if (character.State == CharacterState.PULLING) newDirection *= -1; // Special case for startup if (CurrentDirection == 0 && newDirection != 0) { if (newDirection != startingDirection) SwitchColliders(character); } if (newDirection != 0 && newDirection != CurrentDirection) { SwitchColliders(character); CurrentDirection = newDirection; return true; } return false; }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN) { character.Velocity = new Vector3(character.Velocity.x, springForce); } }
void OnGUI() { controller = (RaycastCharacterController)EditorGUILayout.ObjectField(controller, typeof(RaycastCharacterController), true); if (GUILayout.Button(new GUIContent("Recalculate Now", "Press to automatically generate values based on the controller and total height. Some tweaking may be needed."))) { DoCalculations(); } totalLength = NumberLabel("Total Length", totalLength, "Total ladder size in world units."); ladderWidth = NumberLabel("Ladder Width", ladderWidth, "Width of the ladder in world units."); stepSize = NumberLabel("Step Size", stepSize, "Size of each step."); stepDistance = NumberLabel("Step Distance", stepDistance, "Distance between each step."); useLadderTop = GUILayout.Toggle(useLadderTop, new GUIContent("Use Ladder Top", "Have a rigid top the user can stand on.")); if (useLadderTop) { ladderTopDistance = NumberLabel("Ladder Top Offset", ladderTopDistance, "The offset from the top of the ladder in which the 'climb to top' animation is triggered."); } generateMesh = GUILayout.Toggle(generateMesh, new GUIContent("Generate View", "Instantiate a prefab for the ladders view and scale it to the ladder bounds.")); if (generateMesh) { GUILayout.BeginHorizontal(); GUILayout.Label("View Prefab", GUILayout.Width(100)); GUILayout.FlexibleSpace(); GUILayout.Box(new GUIContent("", "Select a prefab to use for the ladder view."), GUILayout.Width(100)); meshPrefab = (GameObject)EditorGUI.ObjectField(GUILayoutUtility.GetLastRect(), meshPrefab, typeof(GameObject), false); GUILayout.EndHorizontal(); } if (GUILayout.Button(new GUIContent("Generate Ladder", "Create the ladder!"))) { GenerateLadder(); } }
public override void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (character.StartedClimbing) { // Swing rope if (character.characterInput.x > 0.0f && control.LastSwingDirection <= 0.0f) { swingForce = new Vector3(Mathf.Abs (Mathf.Cos(Mathf.Deg2Rad * myTransform.rotation.eulerAngles.z)) * character.climbing.ropeSwingForce, 0.0f, 0.0f); control.LastSwingDirection = 1; control.hasSwung = true; } else if (character.characterInput.x < 0.0f && control.LastSwingDirection >= 0.0f) { swingForce = new Vector3(Mathf.Abs (Mathf.Cos(Mathf.Deg2Rad * myTransform.rotation.eulerAngles.z)) * character.climbing.ropeSwingForce * -1, 0.0f, 0.0f); control.LastSwingDirection = -1; control.hasSwung = true; } // Move up and down rope if (!control.hasClimbed) { Vector2 climbForce = Vector2.zero; if (character.characterInput.y > 0.0f) { control.hasClimbed = true; climbForce.y = character.climbing.speed * RaycastCharacterController.FrameTime; } else if (character.characterInput.y < 0.0f) { control.hasClimbed = true; climbForce.y = -1 * character.climbing.speed * RaycastCharacterController.FrameTime; } character.transform.Translate(0.0f, Vector2.Dot(climbForce, myTransform.rotation * Vector2.up), 0.0f, Space.Self); float delta = myTransform.position.x - character.transform.position.x; character.transform.Translate(RaycastCharacterController.FrameTime * delta, 0.0f, 0.0f, Space.Self); } } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (character.StartedClimbing) { // Move off ladder if (control.dismountWithArrows && character.characterInput.x != 0.0f) { character.Dismount(this); } } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN) { characterIsOnMe = true; standTimer = standTime; } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (character.FallThroughTimer <= 0.0f && collider.direction == RC_Direction.DOWN && character.characterInput.y < 0.0f && (!requireJump || character.characterInput.jumpButtonDown)) { character.FallThroughTimer = fallThroughTime; character.characterInput.CancelJump(); } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { // Hitting from below if (collider.direction == RC_Direction.UP) { if (particles != null) particles.Play(); myCollider.enabled = false; myRenderer.enabled = false; } }
/// <summary> /// Respawn the character at the given point. /// </summary> public static void Respawn(RaycastCharacterController character) { if (currentRespawnPoint != null) { character.Velocity = Vector2.zero; character.transform.position = currentRespawnPoint.myTransform.position + currentRespawnPoint.respawnPositionOffset; } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN && !fallStarted) { fallStarted = true; StartCoroutine(Fall()); } }
protected void Load() { if (controller == null) { controller = (RaycastCharacterController)FindObjectOfType(typeof(RaycastCharacterController)); } DoCalculations(); }
void Start() { if (controller == null) { controller = GetComponent <RaycastCharacterController>(); } // Register listeners controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate(CharacterAnimationEvent); }
void Start() { if (controller == null) controller = gameObject.GetComponent<RaycastCharacterController>(); if (controller == null) { Debug.LogError("FallDamage script not attached to a character"); } else { // Register listeners controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate (CharacterAnimationEvent); } }
void OnTriggerEnter(Collider other) { RaycastCharacterController controller = other.transform.parent.gameObject.GetComponent <RaycastCharacterController> (); if (controller != null) { controller.IsSwimming = true; } }
override public Transform ParentOnStand (RaycastCharacterController character) { if (rigidbody.velocity.y > velocityForFall) { return myTransform; } if (character.transform.parent != null) { character.Velocity = new Vector2 (character.Velocity.x, rigidbody.velocity.y); character.transform.parent = null; } return null; }
/// <summary> /// Latch the specified controller on to the box. /// </summary> /// <param name="controller">Controller to latch.</param> /// <param name="direction">Direction of the latch.</param> private void Latch(RaycastCharacterController controller, RC_Direction direction) { BoxPuller puller = controller.GetComponent <BoxPuller>(); if (IsGrounded(groundedLookAhead) && (puller == null || puller.CanLatch(this))) { this.direction = direction; this.controller = controller; gameObject.layer = latchedLayer; } }
/// <summary> /// Initialise variables. /// </summary> void Start() { health = maxHealth; if (controller == null) { controller = gameObject.GetComponent <RaycastCharacterController>(); } if (controller == null) { Debug.LogError("SimpleHealth script not attached to a character"); } }
override public Transform ParentOnStand(RaycastCharacterController character) { if ((character.StartedClimbing || character.characterInput.y < 0.0f)) { actAsGround = false; } else { actAsGround = true; } return(transform); }
override public CharacterState GetAnimationState(RaycastCharacterController character) { if (control.canClimb && control.hasClimbed) { return(CharacterState.ROPE_CLIMBING); } if (control.hasSwung) { return(CharacterState.ROPE_SWING); } return(CharacterState.ROPE_HANGING); }
/// <summary> /// Stand on a respawn point to activate it. You could play a particle effect of something here. /// </summary> override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (RespawnPoint.currentRespawnPoint is RespawnFlag2DTK) { ((RespawnFlag2DTK)RespawnPoint.currentRespawnPoint).Down(); } if (collider.direction == RC_Direction.DOWN) { RespawnPoint.currentRespawnPoint = this; } sprite.SetSprite(sprite.GetSpriteIdByName(flagUpSprite)); }
/// <summary> /// When hit from the sides latch the character (unless we have a box on top of us). /// </summary> public override void DoAction(RaycastCollider collider, RaycastCharacterController controller) { if (!BoxOnTop) { if (collider.direction == RC_Direction.LEFT) { Latch(controller, RC_Direction.LEFT); } else if (collider.direction == RC_Direction.RIGHT) { Latch(controller, RC_Direction.RIGHT); } } else { UnLatch(); } }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { // Hitting from below (i.e. a headbutt) if (isActive && collider.direction == RC_Direction.UP) { StartCoroutine(DoHit()); if (spawnGameObject != null && !hasSpawned) StartCoroutine(DoSpawn()); else if (spawnGameObject != null) DoBobble(); } // Kill enemies above else if (!isActive && collider.direction == RC_Direction.DOWN && character is IEnemy) { ((IEnemy)character).Kill(); } }
/// <summary> /// Unlatch the latched controller /// </summary> private void UnLatch() { if (controller != null) { BoxPuller puller = controller.GetComponent <BoxPuller>(); if (puller != null) { puller.ReleaseBox(); } } gameObject.layer = backgroundLayer; controller = null; }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { // Hitting from below if (collider.direction == RC_Direction.UP) { if (particles != null) { particles.Play(); } myCollider.enabled = false; myRenderer.enabled = false; } }
override public Transform ParentOnStand(RaycastCharacterController character) { if (GetComponent <Rigidbody>().velocity.y > velocityForFall) { return(myTransform); } if (character.transform.parent != null) { character.Velocity = new Vector2(character.Velocity.x, GetComponent <Rigidbody>().velocity.y); character.transform.parent = null; } return(null); }
/// <summary> /// Call to recalculate the direction. /// </summary> /// <returns><c>true</c>, if colliders were switched, <c>false</c> otherwise.</returns> virtual public bool UpdateDirection(RaycastCharacterController character) { int newDirection = 0; // Always return ledge hang dir - NEW if (character.IsLedgeHanging) { if (character.LedgeHangDirection == RC_Direction.RIGHT) { newDirection = 1; } if (character.LedgeHangDirection == RC_Direction.LEFT) { newDirection = -1; } } if (character.characterInput.x > 0.0f) { newDirection = 1; } if (character.characterInput.x < 0.0f) { newDirection = -1; } //if (character.Velocity.x > 0.0f) newDirection = 1; //if (character.Velocity.x < 0.0f) newDirection = -1; // If PULLING then return oppoiste direction if (character.State == CharacterState.PULLING) { newDirection *= -1; } // Special case for startup if (CurrentDirection == 0 && newDirection != 0) { if (newDirection != startingDirection) { SwitchColliders(character); } } if (newDirection != 0 && newDirection != CurrentDirection) { SwitchColliders(character); CurrentDirection = newDirection; return(true); } return(false); }
override public Transform ParentOnStand(RaycastCharacterController character) { if (character.StartedClimbing) { // Not on the same rope if (!(character.MyParent is Ladder && ((Ladder)character.MyParent).control == control)) { // Centre on rope if (control.snapToMiddle) { float delta = myTransform.position.x - character.transform.position.x; character.transform.Translate(delta, 0.0f, 0.0f, Space.Self); } } return transform; } return null; }
public void KillFromAbove(HitBox other, Collider me) { if (!hasHitPlayer && other != null && other.simplehealth != null) { // If we can find a character controller RaycastCharacterController hero = other.simplehealth.GetComponent <RaycastCharacterController>(); if (hero != null) { me.collider.enabled = false; Kill(); hero.Velocity = new Vector2(hero.Velocity.x, bounceVelocity); } } }
override public Transform ParentOnStand(RaycastCharacterController character) { if (character.StartedClimbing) { // Not on the same rope if (!(character.MyParent is Rope && ((Rope)character.MyParent).control == control)) { control.LastSwingDirection = 0.0f; myRigidbody.AddForce(character.Velocity.x * 0.5f, 0.0f, 0.0f, ForceMode.VelocityChange); character.Velocity = Vector2.zero; // Centre on rope float delta = myTransform.position.x - character.transform.position.x; character.transform.Translate(delta, 0.0f, 0.0f, Space.Self); } return myRigidbody.transform; } return null; }
void Start() { if (controller == null) { controller = gameObject.GetComponent <RaycastCharacterController>(); } if (controller == null) { Debug.LogError("FallDamage script not attached to a character"); } else { // Register listeners controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate(CharacterAnimationEvent); } }
void Start() { pausedLogo = GameObject.FindGameObjectWithTag("Pause"); pausedLogoSprite = GameObject.FindGameObjectWithTag("Pause").GetComponent <UISprite>(); enablePauseLogo(false); _originalTimeScale = Time.timeScale; _originalFixedDeltaTime = Time.fixedDeltaTime; _AnimationCompleted = playerSprite.AnimationCompleted; _status = (Status)GetComponent <Status> (); _camera = GameObject.FindGameObjectWithTag("MainCamera"); _grayscaleEffect = (GrayscaleEffect)_camera.gameObject.GetComponent <GrayscaleEffect> (); _rcc = (RaycastCharacterController)GetComponent("RaycastCharacterController"); _insufficientManaCFX = transform.FindChild("CFX_Text_Insufficient_Mana").particleSystem; }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { // Hitting from below (i.e. a headbutt) if (isActive && collider.direction == RC_Direction.UP) { StartCoroutine(DoHit()); if (spawnGameObject != null && !hasSpawned) { DoSpawn(); } } // Kill enemies above else if (!isActive && collider.direction == RC_Direction.DOWN && character is IEnemy) { ((IEnemy)character).KillFromBelow(spawnForce.y); } }
override public Transform ParentOnStand(RaycastCharacterController character) { if (character.StartedClimbing) { // Not on the same rope if (!(character.MyParent is Ladder && ((Ladder)character.MyParent).control == control)) { // Centre on rope if (control.snapToMiddle) { float delta = myTransform.position.x - character.transform.position.x; character.transform.Translate(delta, 0.0f, 0.0f, Space.Self); } } return(transform); } return(null); }
override public Transform ParentOnStand(RaycastCharacterController character) { if (character.StartedClimbing) { // Not on the same rope if (!(character.MyParent is Rope && ((Rope)character.MyParent).control == control)) { control.LastSwingDirection = 0.0f; myRigidbody.AddForce(character.Velocity.x * 0.5f, 0.0f, 0.0f, ForceMode.VelocityChange); character.Velocity = Vector2.zero; // Centre on rope float delta = myTransform.position.x - character.transform.position.x; character.transform.Translate(delta, 0.0f, 0.0f, Space.Self); } return(myRigidbody.transform); } return(null); }
/// <summary> /// When hit from the sides latch the character (unless we have a box on top of us). /// </summary> override public void DoAction(RaycastCollider collider, RaycastCharacterController controller) { if (!BoxOnTop) { if (collider.direction == RC_Direction.LEFT) { Latch(controller, RC_Direction.LEFT); } else if (collider.direction == RC_Direction.RIGHT) { Latch(controller, RC_Direction.RIGHT); } } else { UnLatch(); } }
void Start() { if (input == null) { input = gameObject.GetComponent <RaycastCharacterInput>(); } if (input == null) { Debug.LogError("Float script does not have an input"); } if (controller == null) { controller = gameObject.GetComponent <RaycastCharacterController>(); } if (controller == null) { Debug.LogError("Float script not attached to a character"); } }
void OnGUI() { controller = (RaycastCharacterController) EditorGUILayout.ObjectField(controller, typeof(RaycastCharacterController), true); if (GUILayout.Button (new GUIContent("Recalculate Now", "Press to automatically generate values based on the controller and total height. Some tweaking may be needed."))){ DoCalculations(); } totalLength = NumberLabel("Total Length", totalLength, "Total ladder size in world units."); ladderWidth = NumberLabel("Ladder Width", ladderWidth, "Width of the ladder in world units."); stepSize = NumberLabel("Step Size", stepSize, "Size of each step."); stepDistance = NumberLabel("Step Distance", stepDistance, "Distance between each step."); useLadderTop = GUILayout.Toggle(useLadderTop, new GUIContent("Use Ladder Top", "Have a rigid top the user can stand on.")); if (useLadderTop) ladderTopDistance = NumberLabel("Ladder Top Offset", ladderTopDistance, "The offset from the top of the ladder in which the 'climb to top' animation is triggered."); generateMesh = GUILayout.Toggle(generateMesh, new GUIContent("Generate View", "Instantiate a prefab for the ladders view and scale it to the ladder bounds.")); if (generateMesh) { GUILayout.BeginHorizontal(); GUILayout.Label("View Prefab", GUILayout.Width(100)); GUILayout.FlexibleSpace(); GUILayout.Box (new GUIContent("", "Select a prefab to use for the ladder view."), GUILayout.Width(100)); meshPrefab = (GameObject) EditorGUI.ObjectField(GUILayoutUtility.GetLastRect(), meshPrefab, typeof(GameObject), false); GUILayout.EndHorizontal(); } if (GUILayout.Button (new GUIContent("Generate Ladder", "Create the ladder!"))) { GenerateLadder(); } }
void Start(){ if (controller == null) controller = GetComponent<RaycastCharacterController>(); // Register listeners controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate (CharacterAnimationEvent); }
protected void Load() { if (controller == null) controller = (RaycastCharacterController) FindObjectOfType(typeof(RaycastCharacterController)); DoCalculations(); }
/// <summary> /// Latch the specified controller on to the box. /// </summary> /// <param name="controller">Controller to latch.</param> /// <param name="direction">Direction of the latch.</param> private void Latch(RaycastCharacterController controller, RC_Direction direction) { BoxPuller puller = controller.GetComponent<BoxPuller>(); if (IsGrounded(groundedLookAhead) && (puller == null || puller.CanLatch(this) )) { this.direction = direction; this.controller = controller; gameObject.layer = latchedLayer; } }
/// <summary> /// Stand on a respawn point to activate it. You could play a particle effect of something here. /// </summary> override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (collider.direction == RC_Direction.DOWN) currentRespawnPoint = this; }
override public Transform ParentOnStand(RaycastCharacterController character) { if ((character.StartedClimbing || character.characterInput.y < 0.0f)) actAsGround = false; else actAsGround = true; return transform; }
/// <summary> /// Unlatch the latched controller /// </summary> private void UnLatch() { if (controller != null) { BoxPuller puller = controller.GetComponent<BoxPuller>(); if (puller != null) puller.ReleaseBox(); } gameObject.layer = backgroundLayer; controller = null; }
void Start () { if (input == null) input = gameObject.GetComponent<RaycastCharacterInput>(); if (input == null) Debug.LogError("Float script does not have an input"); if (controller == null) controller = gameObject.GetComponent<RaycastCharacterController>(); if (controller == null) Debug.LogError("Float script not attached to a character"); }
/// <summary> /// Does this platform want to have this platform become the characters parent. Used for moving platforms. /// </summary> override public Transform ParentOnStand(RaycastCharacterController character) { return myTransform; }
/// <summary> /// Initialise variables. /// </summary> void Start() { health = maxHealth; if (controller == null) controller = gameObject.GetComponent<RaycastCharacterController>(); if (controller == null) Debug.LogError("SimpleHealth script not attached to a character"); }
virtual protected void SwitchColliders(RaycastCharacterController character) { character.SwitchColliders (); }
public override CharacterState GetAnimationState(RaycastCharacterController character) { if (control.canClimb && control.hasClimbed) return CharacterState.ROPE_CLIMBING; if (control.hasSwung) return CharacterState.ROPE_SWING; return CharacterState.ROPE_HANGING; }
/// <summary> /// This is called when a platform is hit. Override to implement platform behaviour. /// </summary> /// <param name='collider'> /// The collider that did the hitting. /// </param> /// <param name='character'> /// The character that did the hitting. /// </param> virtual public void DoAction(RaycastCollider collider, RaycastCharacterController character) { // Do nothing }
override public void DoAction(RaycastCollider collider, RaycastCharacterController character) { if (character.FallThroughTimer <= 0.0f && collider.direction == RC_Direction.DOWN && character.characterInput.y < 0.0f && (!requireJump ||character.characterInput.jumpButtonDown)) { character.FallThroughTimer = fallThroughTime; character.characterInput.CancelJump(); } }
/// <summary> /// Does this platform want to have this platform become the characters parent. Used for moving platforms. /// </summary> /// <returns> /// Return a transform if you want to reparent the character. /// </returns> virtual public Transform ParentOnStand(RaycastCharacterController character) { return null; }
/// <summary> /// Gets the animation for the character. Only called if you have set overrideAnimation to true. /// </summary> /// <returns> /// The animation state. /// </returns> virtual public CharacterState GetAnimationState(RaycastCharacterController character) { return CharacterState.IDLE; }