コード例 #1
0
 // Start is called before the first frame update
 void Start()
 {
     timer = gameObject.AddComponent <SerialObjectTaskTimer>();
     for (int listIndex = 0; listIndex < 5; ++listIndex)
     {
         SerialObjectTaskTimer.ObjectTaskList objectList = new SerialObjectTaskTimer.ObjectTaskList(0.1f + 0.1f * listIndex);
         for (int objIndex = 0; objIndex < 5; ++objIndex)
         {
             objectList.objects.Add(new GameObject("List " + listIndex + " Object " + objIndex));
         }
         timer.AddObjectList(objectList);
     }
     timer.OnObjectPing        += ObjectPing;
     timer.OnAllListsCompleted += OnObjectsCompleted;
     timer.BeginObjectTasks();
 }
コード例 #2
0
    public void SetupLevel(MazeLevel levelData)
    {
        objectRevealTimer.Clear();
        objectRevealTimer.AddObjectList(new SerialObjectTaskTimer.ObjectTaskList(blocksInitialRevealDelay));
        objectRevealTimer.AddObjectList(new SerialObjectTaskTimer.ObjectTaskList(camRevealDelay));
        objectRevealTimer.AddObjectList(new SerialObjectTaskTimer.ObjectTaskList(panelRevealDelay));

        if (UDLRCameraController.Instance != null)
        {
            CamAnimator[] animators = UDLRCameraController.Instance.GetCameraAnimators();
            CameraPanel.DisplayPosition[] camRevealOrder = { CameraPanel.DisplayPosition.TopLeft,     CameraPanel.DisplayPosition.TopRight,
                                                             CameraPanel.DisplayPosition.BottomRight, CameraPanel.DisplayPosition.BottomLeft };
            for (int i = 0; i < camRevealOrder.Length; ++i)
            {
                if (LevelController.Instance.LevelCollection.levels[LevelController.Instance.levelIndex].cameraToggles[(int)camRevealOrder[i]])
                {
                    foreach (CamAnimator camAnim in animators)
                    {
                        if (camAnim != null && camAnim.CameraPanel.camPosition == camRevealOrder[i])
                        {
                            HideObjectAndAddToRevealList(camAnim.gameObject, (int)VisibilityState.RevealingCameras);
                            break;
                        }
                    }
                }
            }
        }
        foreach (RotatorTriggerData rotator in levelData.rotators)
        {
            GameObject           rotatorTriggerObj = Instantiate(rotatorCubePrefab, rotator.position, Quaternion.identity);
            CameraRotatorTrigger rotatorTrigger    = rotatorTriggerObj.GetComponent <CameraRotatorTrigger>();
            if (rotatorTrigger != null)
            {
                rotatorTrigger.arcType = rotator.arcType;
            }
            HideObjectAndAddToRevealList(rotatorTriggerObj, (int)VisibilityState.RevealingObjects);
        }
        if (InputHandler.Instance != null)
        {
            for (int panelPos = 0; panelPos < (int)CameraPanel.DisplayPosition.NumPositions; ++panelPos)
            {
                if (LevelController.Instance.LevelCollection.levels[LevelController.Instance.levelIndex].cameraToggles[panelPos])
                {
                    GameObject     cube           = Instantiate(playerCubePrefab, levelData.cubeStartPositions[panelPos], Quaternion.identity);
                    CubeController cubeController = cube.GetComponent <CubeController>();
                    Assert.IsNotNull(cubeController);
                    InputHandler.Instance.SetCubeController(panelPos, cubeController);
                    cubeController.associatedPanelPosition = (CameraPanel.DisplayPosition)panelPos;
                    cube.layer = LayerMask.NameToLayer(CameraPanel.PositionLayerNames[panelPos]);
                    HideObjectAndAddToRevealList(cube, (int)VisibilityState.RevealingObjects);
                    GameObject goal           = Instantiate(goalCubePrefab, levelData.goalPositions[panelPos], Quaternion.identity);
                    MazeGoal   goalController = goal.GetComponent <MazeGoal>();
                    Assert.IsNotNull(goalController);
                    goal.layer = LayerMask.NameToLayer(CameraPanel.PositionLayerNames[panelPos]);
                    HideObjectAndAddToRevealList(goal, (int)VisibilityState.RevealingObjects);
                    goalController.associatedDisplayPosition = (CameraPanel.DisplayPosition)panelPos;
                    if (UDLRCameraController.Instance != null)
                    {
                        MeshRenderer meshRenderer = cube.GetComponent <MeshRenderer>();
                        if (meshRenderer != null)
                        {
                            meshRenderer.material.SetColor("_EmissionColor", UDLRCameraController.Instance.GetCameraAnimators()[panelPos].GetCamObjColour());
                        }
                        MeshRenderer goalMeshRenderer = goal.GetComponent <MeshRenderer>();
                        if (goalMeshRenderer != null)
                        {
                            goalMeshRenderer.material.SetColor("_EmissionColor", UDLRCameraController.Instance.GetCameraAnimators()[panelPos].GetCamObjColour());
                        }
                    }
                }
            }
        }
        if (UDLRCameraController.Instance != null)
        {
            UDLRCameraController.Instance.panelController.enabled = false;
            objectRevealTimer.AddObjectToObjectsList(UDLRCameraController.Instance.gameObject, (int)VisibilityState.RevealingPanel);
        }
        objectRevealTimer.BeginObjectTasks();
    }