コード例 #1
0
    private void BuildRoad()
    {
        var cubeType = MapService.GetCubeType(LifeGoalTargetX, LifeGoalTargetZ);

        if (cubeType == CubeTypes.Grass)
        {
            if (GameService.RockCount > 0)
            {
                Progress += Time.deltaTime * ContinueRoadSpeed;
                if (Progress > Mathf.PI * 2f)
                {
                    GameService.RockCount--;
                    MapService.ConvertGrassToRoad(LifeGoalTargetX, LifeGoalTargetZ);
                }

                if (Progress >= Mathf.PI * 2f)
                {
                    Progress -= Mathf.PI * 2f;
                }
            }
            else
            {
                Progress = 0;
            }
        }
        else if (cubeType == CubeTypes.Road)
        {
            var next = RoadPath.Dequeue();
            LifeGoalTargetX = next.X;
            LifeGoalTargetZ = next.Z;
            ScheduleMovingSteps(new[] { next });
        }
    }