Beispiel #1
0
		public override void OnNewStateAdded(RexState _state)
		{
			if(_state.id == WallClingState.idString && wallClingState == null)
			{
				wallClingState = _state as WallClingState;
			}	
		}
Beispiel #2
0
		void Awake()
		{
			id = idString;
			isConcurrent = true;
			willPlayAnimationOnBegin = false;
			dashState = GetComponent<DashState>();
			wallClingState = GetComponent<WallClingState>();
			GetController();
		}
Beispiel #3
0
        //Don't call this directly; this will be auto-called after a successful call to Begin()
        protected IEnumerator AttackCoroutine()
        {
            isAttackActive            = true;
            slots.actor.currentAttack = this;
            currentCooldownFrame      = cooldownFrames;

            if (slots.audio && audioClip)
            {
                slots.actor.PlaySoundIfOnCamera(audioClip, 1.0f, slots.audio);
            }

            if (slots.boxCollider != null && willAutoEnableCollider)
            {
                slots.boxCollider.enabled = true;
            }

            if (slots.spriteRenderer != null)
            {
                slots.spriteRenderer.enabled = true;
            }

            attackDirection = AttackDirection.Ahead;
            if (slots.actor.slots.controller.StateID() == WallClingState.idString)
            {
                WallClingState wallClingState = slots.actor.slots.controller.currentState.GetComponent <WallClingState>();
                if (wallClingState && wallClingState.attacksReverseOnWall)
                {
                    attackDirection = AttackDirection.Behind;
                }
            }

            transform.localScale = (attackDirection == AttackDirection.Ahead) ? new Vector3(1.0f, 1.0f, 1.0f) : new Vector3(-1.0f, 1.0f, 1.0f);

            AnimationClip attackAnimationClip = GetAttackAnimationClip();

            if (attackAnimationClip != null && slots.actor.slots.anim)
            {
                slots.animator.Play(attackAnimationClip.name, 0, 0.0f);
            }

            AnimationClip actorAnimationClip = GetActorAnimationClip();

            if (actorAnimationClip != null && slots.actor.slots.anim)
            {
                float timeToSyncTo = (slots.actor.slots.controller.StateID() == MovingState.idString) ? (float)slots.actor.slots.anim.GetCurrentAnimatorStateInfo(0).normalizedTime : 0.0f;                 //If the slots.actor is moving, sync the move-attack cycle to where their move cycle was

                if (willSyncMoveAnimation)
                {
                    timeToSyncTo = 0.0f;
                }

                slots.actor.slots.anim.Play(actorAnimationClip.name, 0, timeToSyncTo);
            }

            if (projectile.rexPool != null)
            {
                CreateProjectile();
            }

            float durationWithoutAnimation = 0.5f;
            float duration = (attackAnimationClip != null) ? attackAnimationClip.length : durationWithoutAnimation;

            if (attackAnimationClip == null && actorAnimationClip != null)
            {
                duration = actorAnimationClip.length;
            }

            yield return(new WaitForSeconds(duration));

            Reset();

            if (slots.actor != null)
            {
                slots.actor.OnAttackComplete();
            }
        }
Beispiel #4
0
		public override bool CanInitiate()
		{
			bool canInitiateJump = false;
			if(type == JumpType.None)
			{
				canInitiateJump = false;
			}
			else if(controller.StateID() == CrouchState.idString && (!controller.GetComponent<CrouchState>().CanExitCrouch() || !controller.GetComponent<CrouchState>().canJump))
			{
				canInitiateJump = false;
			}
			else if(controller.slots.input && controller.slots.input.verticalAxis == -1.0f && RaycastHelper.DropThroughFloorRaycast((Direction.Vertical)(controller.GravityScaleMultiplier() * -1.0f), controller.slots.actor.GetComponent<BoxCollider2D>())) //Dropping through a one-way ledge instead of jumping
			{
				canInitiateJump = false;
			}
			else if(IsLockedForAttack(Attack.ActionType.Jumping))
			{
				canInitiateJump = false;
			}
			else if(controller.isKnockbackActive || controller.isStunned)
			{
				canInitiateJump = false;
			}
			else if(controller.isDashing && dashState && !dashState.canJump)
			{
				canInitiateJump = false;
			}
			else if(controller.slots.actor && controller.StateID() == LadderState.idString)
			{
				canInitiateJump = false;
			}
			else if(controller.framesSinceDrop < 2)
			{
				canInitiateJump = false;
			}
			else if(wallClingState && wallClingState.IsWallJumpPossible())
			{
				canInitiateJump = false;
			}
			else
			{
				if(type == JumpType.Finite)
				{
					WallClingState wallClingState = controller.GetComponent<WallClingState>();
					if(multipleJumpNumber > 0)
					{
						if((currentJump == 0 && (isGroundedWithJumpButtonUp || (!controller.slots.input && controller.slots.physicsObject.IsOnSurface()))) || (currentJump < multipleJumpNumber && currentJump > 0))
						{
							currentJump ++;
							canInitiateJump = true;
						}
						else if(multipleJumpNumber > 1 && !isJumpActive && canMultiJumpOutOfFall && currentJump < multipleJumpNumber)
						{
							currentJump += 2;
							canInitiateJump = true;
						}
					}
				}
				else if(type == JumpType.Infinite)
				{
					currentJump ++;
					canInitiateJump = true;
				}
			}

			return canInitiateJump;
		}