Esempio n. 1
0
    }//FixedUpdate

    public virtual void Update()
    {
        Vector2 deltaMovement = MvmntCmp.Velocity;

        HandleMovingPlatform(ref deltaMovement);
        HandleMovement(ref deltaMovement);
        DropthroughCmp.Check();

        if (CollisionDetectionCmp.Left || CollisionDetectionCmp.Right)
        {
            MvmntCmp.ResetPushForce();
        }

        HandleVelocity(ref deltaMovement);
        MvmntCmp.SetVelocity(deltaMovement);

        if (this.IsGrounded && !prevGroundState && !DropthroughCmp.IsDropping)
        {
            IsLanded = true;
            this.EOnLanded?.Invoke();
        }//if landed

        if (prevGroundState != this.IsGrounded)
        {
            this.EOnGroundStateChange?.Invoke(this.prevGroundState, this.IsGrounded);
            this.prevGroundState = this.IsGrounded;
        }
    }//Update
Esempio n. 2
0
    }//Start

    public virtual void FixedUpdate()
    {
        if (IsLanded)
        {
            IsLanded         = false;
            bCanToggleLanded = false;
        }//if

        if (IsGrounded && bCanToggleLanded && !DropthroughCmp.IsDropping)
        {
            IsLanded = true;
        }

        if (!this.IsGrounded)
        {
            bCanToggleLanded = true;
        }

        Vector3 deltaMovement = MvmntCmp.Velocity;

        //APPLY GRAVITY
        if (this.Gravity != null)
        {
            this.Gravity.Apply(ref deltaMovement);
        }

        if (DropthroughCmp.IsCanDropthrough)
        {
            if (DropthroughCmp.IsDropping)
            {
                if (!CollisionDetectionCmp.Props.CollisionIgnoreTags.Contains("Platform"))
                {
                    CollisionDetectionCmp.Props.CollisionIgnoreTags.Add("Platform");
                }
            }
            else
            {
                if (CollisionDetectionCmp.Props.CollisionIgnoreTags.Contains("Platform"))
                {
                    CollisionDetectionCmp.Props.CollisionIgnoreTags.Remove("Platform");
                }
            }
        }//if IsCanDropthrough

        CollisionDetectionCmp.Move(ref deltaMovement);

        MvmntCmp.SetVelocity(deltaMovement);
        transform.Translate(MvmntCmp.Velocity);
    }//FixedUpdate
Esempio n. 3
0
    }//HandleVelocity

    public virtual void HandleMovement(ref Vector2 deltaMovement)
    {
        deltaMovement = MvmntCmp.Move(deltaMovement);
    }//HandleMovement