Ejemplo n.º 1
0
        /// <summary>
        /// 给手动清理设置轨道状态用的。因为手动清理轨道没有因为步骤变化图标
        /// </summary>
        /// <param name="railStatus"></param>
        /// <returns></returns>
        public bool SetRailStatus(RailStatus railStatus)
        {
            RailMode mode = GetWorkingRail();

            if (mode == null)
            {
                return(false);
            }

            mode.Status = railStatus;

            return(true);
        }
Ejemplo n.º 2
0
    void ChangeRail(int direction)
    {
        float maxUp       = 3f;
        float maxDist     = 6f;
        var   saveSpeed   = rb.velocity;
        var   saveAngular = rb.angularVelocity;
        int   dist        = 2;

        float forwardLook = rb.velocity.x * 1f;

        Ray        ray = new Ray(transform.position + Vector3.forward * dist * direction + Vector3.up * maxUp + Vector3.right * (forwardLook), Vector3.down);
        RaycastHit hit;
        bool       success = Physics.Raycast(ray, out hit, maxDist);

        Vector3 landingSpot = Vector3.zero;

        if (success)
        {
            landingSpot = hit.point;
        }
        else
        {
            dist    = 4;
            ray     = new Ray(transform.position + Vector3.forward * dist * direction + Vector3.up * maxUp + Vector3.right * (forwardLook), Vector3.down);
            success = Physics.Raycast(ray, out hit, maxDist);
            if (success)
            {
                landingSpot = hit.point;
            }
            else
            {
                dist    = 6;
                ray     = new Ray(transform.position + Vector3.forward * dist * direction + Vector3.up * maxUp + Vector3.right * (forwardLook), Vector3.down);
                success = Physics.Raycast(ray, out hit, maxDist);
                if (success)
                {
                    landingSpot = hit.point;
                }
            }
        }

        if (!success)
        {
            landingSpot = transform.position + Vector3.forward * 2 * direction;
            dist        = 2;
        }

        Debug.DrawLine(transform.position, landingSpot, success ? Color.green : Color.red, 100);

        readyToRailChange = false;
        grounded          = false;
        rb.isKinematic    = true;
        railStatus        = RailStatus.Jumping;
        aus.clip          = Jump;
        aus.Play();

        float animationSpeedFactor = 0.2f;
        float elevation            = 1.5f;
        float apexHeight           = Mathf.Max(landingSpot.y + elevation, transform.position.y + elevation);
        float jumpHeight           = apexHeight - transform.position.y;
        float jumpUpTime           = jumpHeight * animationSpeedFactor;
        float jumpDownTime         = (apexHeight - landingSpot.y) * animationSpeedFactor;
        float jumpTime             = jumpUpTime + jumpDownTime;

        var sequence = DOTween.Sequence();

        sequence.Append(transform.DOMoveY(apexHeight, jumpUpTime).SetEase(Ease.OutQuad));
        sequence.Append(transform.DOMoveY(landingSpot.y + 0.5f, jumpDownTime).SetEase(Ease.InQuad));
        sequence.AppendCallback(() => rail -= direction * (dist / 2));
        sequence.AppendCallback(() => { rb.isKinematic = false; railStatus = RailStatus.OnTrack; });
        sequence.AppendCallback(() => { rb.velocity = Vector3.right * saveSpeed.x + Vector3.down * fallSpeed; rb.angularVelocity = saveAngular; });
        sequence.Insert(0, transform.DOMoveZ(dist * direction, jumpTime).SetEase(Ease.OutQuad).SetRelative(true));
        sequence.Insert(0, transform.DORotate(Vector3.right * 180f * direction, jumpTime, RotateMode.WorldAxisAdd).SetEase(Ease.OutBack).SetRelative(true));
        sequence.Insert(0, transform.DOMoveX(landingSpot.x, jumpTime).SetEase(Ease.Linear));
    }
Ejemplo n.º 3
0
 internal Rail(Rail previous)
 {
     this.Index = previous.Index;
     this.Status = previous.Status;
     this.Updated = false;
     this.StartX = previous.EndX;
     this.StartY = previous.EndY;
     this.EndX = previous.EndX;
     this.EndY = previous.EndY;
     this.Type = previous.Type;
     this.WallType = previous.WallType;
     this.WallSide = previous.WallSide;
     this.DikeType = previous.DikeType;
     this.DikeSide = previous.DikeSide;
     this.Pole = previous.Pole;
     this.Forms = null;
     this.FormCount = 0;
     this.Cracks = null;
     this.CrackCount = 0;
     this.FreeObjs = null;
     this.FreeObjCount = 0;
     this.Beacons = null;
     this.BeaconCount = 0;
     this.Stops = null;
     this.StopCount = 0;
     this.Limits = null;
     this.LimitCount = 0;
 }
Ejemplo n.º 4
0
 // constructors
 internal Rail(int index)
 {
     this.Index = index;
     this.Status = RailStatus.NotAvailable;
     this.Updated = false;
     this.StartX = 0.0;
     this.StartY = 0.0;
     this.EndX = 0.0;
     this.EndY = 0.0;
     this.Type = 0;
     this.WallType = -1;
     this.WallSide = 0;
     this.DikeType = -1;
     this.DikeSide = 0;
     this.Pole = new Pole(-1, 0, 0.0, 1);
     this.Forms = null;
     this.FormCount = 0;
     this.Cracks = null;
     this.CrackCount = 0;
     this.FreeObjs = null;
     this.FreeObjCount = 0;
     this.Beacons = null;
     this.BeaconCount = 0;
     this.Stops = null;
     this.StopCount = 0;
     this.Limits = null;
     this.LimitCount = 0;
 }