コード例 #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;
     }
 }
コード例 #2
0
ファイル: SlipperyPlatform.cs プロジェクト: devNaroo/2DWalker
	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;
		}
	}
コード例 #3
0
 public override void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN) {
         characterIsOnMe = true;
         standTimer = standTime;
     }
 }
コード例 #4
0
 public override void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN && !fallStarted) {
         fallStarted = true;
         StartCoroutine(Fall());
     }
 }
コード例 #5
0
 void Start()
 {
     if (controller == null)
     {
         controller = GetComponent <RaycastCharacterController>();
     }
 }
コード例 #6
0
ファイル: DirectionChecker.cs プロジェクト: devNaroo/2DWalker
	/// <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;
	}
コード例 #7
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         character.Velocity = new Vector3(character.Velocity.x, springForce);
     }
 }
コード例 #8
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();
     }
 }
コード例 #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);
         }
     }
 }
コード例 #10
0
ファイル: LadderCollider.cs プロジェクト: devNaroo/2DWalker
	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);
			}
		} 
	}
コード例 #11
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN)
     {
         characterIsOnMe = true;
         standTimer      = standTime;
     }
 }
コード例 #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();
     }
 }
コード例 #13
0
ファイル: Brick.cs プロジェクト: devNaroo/2DWalker
	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;
		}
	}
コード例 #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;
     }
 }
コード例 #15
0
 override public void DoAction(RaycastCollider collider, RaycastCharacterController character)
 {
     if (collider.direction == RC_Direction.DOWN && !fallStarted)
     {
         fallStarted = true;
         StartCoroutine(Fall());
     }
 }
コード例 #16
0
 protected void Load()
 {
     if (controller == null)
     {
         controller = (RaycastCharacterController)FindObjectOfType(typeof(RaycastCharacterController));
     }
     DoCalculations();
 }
コード例 #17
0
 void Start()
 {
     if (controller == null)
     {
         controller = GetComponent <RaycastCharacterController>();
     }
     // Register listeners
     controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate(CharacterAnimationEvent);
 }
コード例 #18
0
ファイル: FallDamage.cs プロジェクト: devNaroo/2DWalker
	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);
		}
	}
コード例 #19
0
    void OnTriggerEnter(Collider other)
    {
        RaycastCharacterController controller = other.transform.parent.gameObject.GetComponent <RaycastCharacterController> ();

        if (controller != null)
        {
            controller.IsSwimming = true;
        }
    }
コード例 #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;
     }
 }
コード例 #21
0
ファイル: FallingPlatform.cs プロジェクト: devNaroo/2DWalker
	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;
	}
コード例 #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);
         }
     }
 }
コード例 #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;
        }
    }
コード例 #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");
     }
 }
コード例 #25
0
 override public Transform ParentOnStand(RaycastCharacterController character)
 {
     if ((character.StartedClimbing || character.characterInput.y < 0.0f))
     {
         actAsGround = false;
     }
     else
     {
         actAsGround = true;
     }
     return(transform);
 }
コード例 #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);
 }
コード例 #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));
 }
コード例 #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();
     }
 }
コード例 #29
0
ファイル: UnBreakableBrick.cs プロジェクト: devNaroo/2DWalker
	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();
		}
	}
コード例 #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;
 }
コード例 #31
0
ファイル: Brick.cs プロジェクト: keiranlovett/Nocturnal
 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;
     }
 }
コード例 #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);
 }
コード例 #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);
    }
コード例 #34
0
ファイル: LadderCollider.cs プロジェクト: devNaroo/2DWalker
	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;
	}
コード例 #35
0
ファイル: EnemyPatrol.cs プロジェクト: keiranlovett/Nocturnal
 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);
         }
     }
 }
コード例 #36
0
ファイル: RopeCollider.cs プロジェクト: devNaroo/2DWalker
	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;
	}
コード例 #37
0
ファイル: FallDamage.cs プロジェクト: keiranlovett/Nocturnal
 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);
     }
 }
コード例 #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;
    }
コード例 #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);
     }
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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();
     }
 }
コード例 #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");
     }
 }
コード例 #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();
		}
	}
コード例 #45
0
ファイル: AnimationLogger.cs プロジェクト: devNaroo/2DWalker
	void Start(){
		if (controller == null) controller = GetComponent<RaycastCharacterController>();
		// Register listeners
		controller.CharacterAnimationEvent += new RaycastCharacterController.CharacterControllerEventDelegate (CharacterAnimationEvent);
		
	}
コード例 #46
0
ファイル: RespawnPoint.cs プロジェクト: devNaroo/2DWalker
	/// <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;
		}
	}
コード例 #47
0
	protected void Load() {
		if (controller == null) controller = (RaycastCharacterController) FindObjectOfType(typeof(RaycastCharacterController));
		DoCalculations();
	}
コード例 #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;
		}
	}
コード例 #49
0
ファイル: RespawnPoint.cs プロジェクト: devNaroo/2DWalker
	/// <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;
	}
コード例 #50
0
ファイル: TopStepPlatform.cs プロジェクト: devNaroo/2DWalker
	override public Transform ParentOnStand(RaycastCharacterController character) {
		if ((character.StartedClimbing || character.characterInput.y < 0.0f)) actAsGround = false;
		else actAsGround = true;
		return transform;
	}
コード例 #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;
	}
コード例 #52
0
ファイル: Float.cs プロジェクト: devNaroo/2DWalker
	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");
	}
コード例 #53
0
ファイル: BarrelPlatform.cs プロジェクト: devNaroo/2DWalker
	/// <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;	
	}
コード例 #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");
 }
コード例 #55
0
ファイル: DirectionChecker.cs プロジェクト: devNaroo/2DWalker
	virtual protected void SwitchColliders(RaycastCharacterController character) {
		character.SwitchColliders ();
	}
コード例 #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;
 }
コード例 #57
0
ファイル: Platform.cs プロジェクト: devNaroo/2DWalker
	/// <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
	}
コード例 #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();
		}
	}
コード例 #59
0
ファイル: Platform.cs プロジェクト: devNaroo/2DWalker
	/// <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;	
	}
コード例 #60
0
ファイル: Platform.cs プロジェクト: devNaroo/2DWalker
	/// <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;
	}