Пример #1
0
    public void StartMinigame(MinigameDisplayComponent display, MinigameType type, int playerID, Action <MinigameTickResult> callback = null)
    {
        BaseMinigame minigame = null;

        switch (type)
        {
        case MinigameType.Sequence:

            minigame = new SequenceMinigame();
            minigame.Setup(m_CurrentMinigameID, display, new Rect(100, 100, 10, 10), playerID, callback);
            break;

        case MinigameType.Screwdriver:

            minigame = new ScrewdriverMinigame();
            minigame.Setup(m_CurrentMinigameID, display, new Rect(200, 100, 10, 10), playerID, callback);
            break;

        case MinigameType.Morse:

            minigame = new MorseMinigame();
            minigame.Setup(m_CurrentMinigameID, display, new Rect(300, 100, 10, 10), playerID, callback);
            break;

        case MinigameType.Matcher:

            minigame = new MatcherMinigame();
            minigame.Setup(m_CurrentMinigameID, display, new Rect(400, 100, 10, 10), playerID, callback);
            break;
        }

        BeginMinigame(minigame);

        m_CurrentMinigameID++;
    }
Пример #2
0
    public void Setup(int id, MinigameDisplayComponent displayComponent, Rect rect, int playerID, Action <MinigameTickResult> callback = null)
    {
        m_MiniGameID       = id;
        m_DisplayComponent = displayComponent;
        m_PlayerID         = playerID;
        m_GamePlayRect     = rect;
        FinishCallback     = callback;

        GameObject cameraObject = new GameObject("Minigame Camera");

        cameraObject.transform.localRotation = Quaternion.Euler(90, 0, 0);
        m_MinigameCamera = cameraObject.AddComponent <Camera>();
        m_MinigameCamera.transform.position = new Vector3(rect.center.x, 5.0f, rect.center.y);
        m_MinigameCamera.orthographic       = true;
        m_MinigameCamera.aspect             = rect.size.x / rect.size.y;
        m_MinigameCamera.orthographicSize   = rect.size.x / 2.0f;

        m_RenderTexture = new RenderTexture((int)rect.size.x * 64, (int)rect.size.y * 64, 24, RenderTextureFormat.Default);
        m_MinigameCamera.targetTexture = m_RenderTexture;
        m_DisplayComponent.SetRenderTexture(m_RenderTexture);
    }