Exemplo n.º 1
0
    void Update()
    {
        if (pathFindData == null)
        {
            return;
        }

        if (pathFindData.currentMode == 2 &&
            currentPathIndex == pathFindData.currentPath.Count - 1 &&
            !splineFollower.spline.is_connector &&
            percent >= 0.9)
        {
            Destroy(this.gameObject);
            return;
        }

        switch (moveStat)
        {
        case MOVESTAT.ZERO:
            break;

        case MOVESTAT.INCREASE:
            splineFollower.followSpeed = Mathf.Lerp(splineFollower.followSpeed, maxSpeed, Time.deltaTime * acc);
            if (Mathf.Abs(splineFollower.followSpeed - maxSpeed) <= 0.1)
            {
                moveStat = MOVESTAT.ZERO;
            }

            break;

        case MOVESTAT.DECEASE:
            splineFollower.followSpeed = Mathf.Lerp(splineFollower.followSpeed, minSpeed, Time.deltaTime * acc);
            if (Mathf.Abs(splineFollower.followSpeed - minSpeed) <= 0.1)
            {
                splineFollower.follow = false;
                moveStat = MOVESTAT.ZERO;
            }

            break;
        }

        EndBeginEventChecker();
    }
Exemplo n.º 2
0
    // Set Spline to splineFollower.spline
    public void SetNextRoad(SplineComputer _spline, bool toConnector)
    {
        if (toConnector)
        {
            moveStat = MOVESTAT.INCREASE;
            maxSpeed = 2.0f;
            var roadConnection = splineFollower.spline.roadConnectionList.FirstOrDefault(rc => rc.GetconnectedRoad() == _spline);

            var cs = roadConnection.GetConnector(true, out var _endO, currentOffset);

            if (cs == null)
            {
                Debug.LogError("Connection is not found!");
            }

            currentOffset = _endO;    // Change Current Offset to last End Offset

            cs.Rebuild(true);

            splineFollower.spline = cs;
            SetMoveDir(true);

            checkingPos = cs.GetPoints().Last().position;
            GameObject.FindGameObjectWithTag("Player").GetComponent <CreatePathManager>().debugPointPer(checkingPos);
        }
        else
        {
            moveStat = MOVESTAT.INCREASE;
            maxSpeed = 4.0f;
            splineFollower.spline = _spline;

            switch (_spline.roadLane)
            {
            case CreatePathManager.ROADLANE.RL1:
                switch (_spline.roadMode)
                {
                case SplineComputer.MODE.FIRST_OPEN:
                    SetMoveDir(true);
                    break;

                case SplineComputer.MODE.LAST_OPEN:
                    SetMoveDir(false);
                    break;
                }
                break;

            case CreatePathManager.ROADLANE.RL2:
                switch (_spline.roadMode)
                {
                case SplineComputer.MODE.FIRST_OPEN:
                    SetMoveDir(true);
                    break;

                case SplineComputer.MODE.LAST_OPEN:
                    SetMoveDir(false);
                    break;
                }
                break;
            }

            EndBeginEventChecker_Prepare();
        }
    }
Exemplo n.º 3
0
 // Disable following
 public void Stop()
 {
     moveStat = MOVESTAT.DECEASE;
 }
Exemplo n.º 4
0
 // Enable following
 public void Run()
 {
     splineFollower.follow = true;
     moveStat = MOVESTAT.INCREASE;
 }