Ejemplo n.º 1
0
 /// <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;
     }
 }
Ejemplo n.º 2
0
	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;
		}
	}
Ejemplo n.º 3
0
 public override void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN) {
         characterIsOnMe = true;
         standTimer = standTime;
     }
 }
Ejemplo n.º 4
0
 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>();
     }
 }
Ejemplo n.º 6
0
	/// <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;
	}
Ejemplo n.º 7
0
 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();
     }
 }
Ejemplo n.º 9
0
 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);
         }
     }
 }
Ejemplo n.º 10
0
	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);
			}
		} 
	}
Ejemplo n.º 11
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         characterIsOnMe = true;
         standTimer      = standTime;
     }
 }
Ejemplo n.º 12
0
 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();
     }
 }
Ejemplo n.º 13
0
	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;
		}
	}
Ejemplo n.º 14
0
 /// <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;
     }
 }
Ejemplo n.º 15
0
 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();
 }
Ejemplo n.º 17
0
 void Start()
 {
     if (controller == null)
     {
         controller = GetComponent <RaycastCharacterController>();
     }
     // Register listeners
     controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate(CharacterAnimationEvent);
 }
Ejemplo n.º 18
0
	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);
		}
	}
Ejemplo n.º 19
0
    void OnTriggerEnter(Collider other)
    {
        RaycastCharacterController controller = other.transform.parent.gameObject.GetComponent <RaycastCharacterController> ();

        if (controller != null)
        {
            controller.IsSwimming = true;
        }
    }
Ejemplo n.º 20
0
 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;
     }
 }
Ejemplo n.º 21
0
	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;
	}
Ejemplo n.º 22
0
 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);
         }
     }
 }
Ejemplo n.º 23
0
    /// <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;
        }
    }
Ejemplo n.º 24
0
 /// <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");
     }
 }
Ejemplo n.º 25
0
 override public Transform ParentOnStand(RaycastCharacterController character)
 {
     if ((character.StartedClimbing || character.characterInput.y < 0.0f))
     {
         actAsGround = false;
     }
     else
     {
         actAsGround = true;
     }
     return(transform);
 }
Ejemplo n.º 26
0
 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);
 }
Ejemplo n.º 27
0
 /// <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));
 }
Ejemplo n.º 28
0
 /// <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();
     }
 }
Ejemplo n.º 29
0
	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();
		}
	}
Ejemplo n.º 30
0
 /// <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;
 }
Ejemplo n.º 31
0
 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;
     }
 }
Ejemplo n.º 32
0
 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);
 }
Ejemplo n.º 33
0
    /// <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);
    }
Ejemplo n.º 34
0
	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;
	}
Ejemplo n.º 35
0
 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);
         }
     }
 }
Ejemplo n.º 36
0
	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;
	}
Ejemplo n.º 37
0
 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);
     }
 }
Ejemplo n.º 38
0
    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;
    }
Ejemplo n.º 39
0
 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);
     }
 }
Ejemplo n.º 40
0
 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);
 }
Ejemplo n.º 41
0
 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);
 }
Ejemplo n.º 42
0
 /// <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();
     }
 }
Ejemplo n.º 43
0
 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");
     }
 }
Ejemplo n.º 44
0
	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();
		}
	}
Ejemplo n.º 45
0
	void Start(){
		if (controller == null) controller = GetComponent<RaycastCharacterController>();
		// Register listeners
		controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate (CharacterAnimationEvent);
		
	}
Ejemplo n.º 46
0
	/// <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;
		}
	}
Ejemplo n.º 47
0
	protected void Load() {
		if (controller == null) controller = (RaycastCharacterController) FindObjectOfType(typeof(RaycastCharacterController));
		DoCalculations();
	}
Ejemplo n.º 48
0
	/// <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;
		}
	}
Ejemplo n.º 49
0
	/// <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;
	}
Ejemplo n.º 50
0
	override public Transform ParentOnStand(RaycastCharacterController character) {
		if ((character.StartedClimbing || character.characterInput.y < 0.0f)) actAsGround = false;
		else actAsGround = true;
		return transform;
	}
Ejemplo n.º 51
0
	/// <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;
	}
Ejemplo n.º 52
0
	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");
	}
Ejemplo n.º 53
0
	/// <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;	
	}
Ejemplo n.º 54
0
 /// <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");
 }
Ejemplo n.º 55
0
	virtual protected void SwitchColliders(RaycastCharacterController character) {
		character.SwitchColliders ();
	}
Ejemplo n.º 56
0
 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;
 }
Ejemplo n.º 57
0
	/// <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
	}
Ejemplo n.º 58
0
	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();
		}
	}
Ejemplo n.º 59
0
	/// <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;	
	}
Ejemplo n.º 60
0
	/// <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;
	}