void SetData(TFPData newData)
 {
     moving              = newData.moving;
     jumpHeld            = newData.jumpHeld;
     crouching           = newData.crouching;
     running             = newData.running;
     mouseLocked         = newData.mouseLocked;
     jumpPressed         = newData.jumpPressed;
     xIn                 = newData.xIn;
     yIn                 = newData.yIn;
     xMouse              = newData.xMouse;
     yMouse              = newData.yMouse;
     jumping             = newData.jumping;
     grounded            = newData.grounded;
     timeSinceGrounded   = newData.timeSinceGrounded;
     yVel                = newData.yVel;
     slide               = newData.slide;
     gravMult            = newData.gravMult;
     currentStrafeMult   = newData.currentStrafeMult;
     currentBackwardMult = newData.currentBackwardMult;
     currentMoveSpeed    = newData.currentMoveSpeed;
     groundAngle         = newData.groundAngle;
     lastMove            = newData.lastMove;
     currentMove         = newData.currentMove;
     forward             = newData.forward;
     side                = newData.side;
     moveDelta           = newData.moveDelta;
     hitNormal           = newData.hitNormal;
     hitPoint            = newData.hitPoint;
     slideMove           = newData.slideMove;
     standingHeight      = newData.standingHeight;
     cameraOffset        = newData.cameraOffset;
 }
Пример #2
0
 public override void ExPostUpdate(ref TFPData data, TFPInfo info)
 {
     if (data.timeSinceGrounded <= Time.deltaTime && data.jumping)
     {
         src.PlayOneShot(sound);
     }
 }
    public override void ExPreMove(ref TFPData data, TFPInfo info)
    {
        Vector3 dir      = data.currentMove * Time.deltaTime;
        Vector3 checkPos = transform.position + dir;

        if (Physics.Raycast(checkPos + Vector3.up, Vector3.down, out hit))
        {
            string  tag          = hit.collider.tag;
            Vector3 step         = -dir.normalized * collisionResolution;
            Vector3 nonTaggedPos = transform.position;
            if (Unwalkable.Contains(tag))
            {
                for (int a = -90; a < 90; a += collisionStepAngle)
                {
                    checkPos = (Quaternion.Euler(0, a, 0) * dir) + transform.position;
                    Physics.Raycast(checkPos + Vector3.up, Vector3.down, out hit);
                    tag = hit.collider.tag;
                    if (!Unwalkable.Contains(tag))
                    {
                        nonTaggedPos = checkPos;
                        if (a > 0)
                        {
                            break;
                        }
                    }
                }
                data.currentMove  = nonTaggedPos - transform.position;
                data.currentMove *= 1 / Time.deltaTime;
            }
        }
    }
Пример #4
0
 public override void ExPreUpdate(ref TFPData data, TFPInfo info)
 {
     if (disablePlayerLook && forceLook)
     {
         data.mouseLookEnabled = false;
     }
     else
     {
         data.mouseLookEnabled = true;
     }
 }
Пример #5
0
 public override void ExPreMove(ref TFPData data, TFPInfo info)
 {
     if ((!data.grounded || data.slide) && !data.jumping)
     {
         if (data.jumpPressed > 0)
         {
             jetting = true;
             data.timeSinceGrounded = info.coyoteTime + Time.deltaTime;
             data.jumpPressed       = 0;
         }
         if (data.jumpHeld && fuelLeft > 0)
         {
             jetting   = true;
             data.yVel = jetPower;
             if (limitFuel)
             {
                 fuelLeft -= Time.deltaTime;
                 if (fuelLeft < 0)
                 {
                     fuelLeft = 0;
                 }
             }
             jetSound.volume = Mathf.MoveTowards(jetSound.volume, 1.0f, soundFadeSpeed * Time.deltaTime);
         }
         else
         {
             jetting = false;
         }
     }
     else if (data.grounded)
     {
         jetting  = false;
         fuelLeft = Mathf.MoveTowards(fuelLeft, fuel, fuelRegain * Time.deltaTime);
     }
     else
     {
         jetting = false;
     }
     if (!jetting)
     {
         jetSound.volume = Mathf.MoveTowards(jetSound.volume, 0.0f, soundFadeSpeed * Time.deltaTime);
     }
     if (fuelLeft < fuel)
     {
         fuelGuage.text = "FUEL: " + fuelLeft.ToString("F2") + " / " + fuel;
     }
     else
     {
         fuelGuage.text = "";
     }
 }
Пример #6
0
    public override void ExPreMove(ref TFPData data, TFPInfo info)
    {
        data.currentMove += floatingPlatform;
        floatingPlatform  = Vector3.zero;
        if (beenPushed)
        {
            data.yVel        += pushDirection.y;
            data.currentMove += new Vector3(pushDirection.x, 0f, pushDirection.z);

            timeSincePushed = Time.time;
            pushDirection   = Vector3.zero;
            control         = 0f;
            beenPushed      = false;
        }
    }
Пример #7
0
 public override void ExPreUpdate(ref TFPData data, TFPInfo info)
 {
     if (control == 0f && Time.time > timeSincePushed + 0.3f && data.grounded)
     {
         control     = 1f;
         data.moving = true;
         print("Regain control");
     }
     else if (control == 0f)
     {
         data.moving = false;
     }
     data.xIn = Mathf.Lerp(data.xIn, 0f, freezePercentage);
     data.yIn = Mathf.Lerp(data.yIn, 0f, freezePercentage);
 }
Пример #8
0
    public override void ExPreMove(ref TFPData data, TFPInfo info)
    {
        if (forceLook)
        {
            GetLastLook(data, info);

            if (isAngle)
            {
                lookAngle = lookValue;
            }
            else
            {
                lookAngle = Quaternion.LookRotation(lookValue - info.cam.position).eulerAngles;
            }

            float   newHorLook = Mathf.MoveTowardsAngle(lastHorLook, lookAngle.y, lookSpeed * Time.deltaTime);
            float   newVerLook = Mathf.MoveTowardsAngle(lastVerLook, lookAngle.x, lookSpeed * Time.deltaTime);
            Vector3 newLook    = new Vector3(newVerLook, newHorLook, 0.0f);
            transform.eulerAngles     = new Vector3(0.0f, newLook.y, 0.0f);
            info.cam.localEulerAngles = new Vector3(newLook.x, 0.0f, 0.0f);
        }
    }
    void ExecuteExtension(string command)
    {
        if (!extensionsEnabled)
        {
            return;
        }
        TFPData data = GetData();

        foreach (TFPExtension extension in Extensions)
        {
            switch (command)
            {
            case "Start":
                extension.ExStart(ref data, controllerInfo);
                break;

            case "PreUpdate":
                extension.ExPreUpdate(ref data, controllerInfo);
                break;

            case "PostUpdate":
                extension.ExPostUpdate(ref data, controllerInfo);
                break;

            case "FixedUpdate":
                extension.ExFixedUpdate(ref data, controllerInfo);
                break;

            case "PreMove":
                extension.ExPreMove(ref data, controllerInfo);
                break;

            default:
                break;
            }
        }
        SetData(data);
    }
Пример #10
0
 public override void ExPostUpdate(ref TFPData data, TFPInfo info)
 {
     if (data.moving && data.grounded)
     {
         float deltaMove = Vector3.Scale(data.lastMove, new Vector3(1, 0, 1)).magnitude *Time.deltaTime;
         leftDistance  -= deltaMove;
         rightDistance -= deltaMove;
         if (leftDistance <= 0)
         {
             leftDistance += distanceBetweenFootsteps * 2;
             leftFoot.PlayOneShot(GetClip(info));
         }
         if (rightDistance <= 0)
         {
             rightDistance += distanceBetweenFootsteps * 2;
             rightFoot.PlayOneShot(GetClip(info));
         }
     }
     else
     {
         leftDistance  = 0;
         rightDistance = distanceBetweenFootsteps;
     }
 }
 //executes during the FixedUpdate function in FPSController.cs. Use for physics interactions
 public virtual void ExFixedUpdate(ref TFPData data, TFPInfo info)
 {
 }
Пример #12
0
 public override void ExPostMove(ref TFPData data, TFPInfo info)
 {
     currentVelocity = data.moveDelta / Time.deltaTime;
     grounded        = data.grounded;
 }
 /*
  * executes before the controller.Move function is called in FPSController.cs
  * YVel is applied to current move after this
  * This means that YVel represents the vertical movement
  * and currentmove represents the horizontal movement
  *
  * use this if you want to add custom movement functionality
  */
 public virtual void ExPreMove(ref TFPData data, TFPInfo info)
 {
 }
 //executes at the end of the Update function in FPSController.cs
 public virtual void ExPostUpdate(ref TFPData data, TFPInfo info)
 {
 }
Пример #15
0
 public override void ExStart(ref TFPData data, TFPInfo info)
 {
     leftDistance  = 0;
     rightDistance = distanceBetweenFootsteps;
 }
Пример #16
0
 public override void ExPostMove(ref TFPData data, TFPInfo info)
 {
     UpdateLine();
 }
Пример #17
0
 public override void ExStart(ref TFPData data, TFPInfo info)
 {
     pos = new Vector3[] { transform.position };
 }
Пример #18
0
 public override void ExStart(ref TFPData data, TFPInfo info)
 {
     fuelLeft = fuel;
 }
Пример #19
0
 void GetLastLook(TFPData data, TFPInfo info)
 {
     lastHorLook = transform.eulerAngles.y;
     lastVerLook = info.cam.localEulerAngles.x;
     lastLook    = new Vector3(lastVerLook, lastHorLook, 0.0f);
 }
 //executes at the end of the Start function in FPSController.cs
 public virtual void ExStart(ref TFPData data, TFPInfo info)
 {
 }