Пример #1
0
    public override void Init(GameObject parentObject)
    {
        ARManager.SetPlanesActive(false); //Incase theres existing planes
        ARManager.SetPlaneManagerActive(false);

        instructionUI.SetActive(true);
        mainMenuButton.SetActive(false);

        if (minionPrefabs != null)
        {
            foreach (Minion m in minionPrefabs)
            {
                minionDictionary.Add(m.gameObject.name, m.gameObject);
            }
        }

        //ARDebug.Log("Loaded prefabs", 5);

        imageManager = FindObjectOfType <ARTrackedImageManager>();
        if (imageManager == null)
        {
            imageManager = ARManager.arSessionOrigin.gameObject.AddComponent <ARTrackedImageManager>();
            imageManager.referenceLibrary        = ContentLoader.LoadReferenceLibrary();
            imageManager.maxNumberOfMovingImages = 2;
            //imageManager.trackedImagePrefab = spawnObject;
        }

        imageManager.enabled = true;
        imageManager.trackedImagesChanged += UpdateImage;

        //ARDebug.Log("Finish Init", 5);
    }
Пример #2
0
    public override void Init(GameObject parentObject)
    {
        ARManager.SetPlaneManagerActive(true);
        ARManager.TogglePlanePrefab(true);


        visualMarkerBlock = Instantiate(visualMarkerBlockPrefab, Vector3.one * 100, Quaternion.identity);
    }
Пример #3
0
    public static IEnumerator RestartARSession()
    {
        ARManager.DestroyCurrentARSession();
        yield return(null);

        ARManager.AssignNewARSession(Instantiate((GameObject)Resources.Load("AR Session")));

        ARManager.SetPlaneManagerActive(false);
    }
Пример #4
0
    IEnumerator RestartLocalARSession()
    {
        yield return(new WaitForSeconds(0.2f));

        StartCoroutine(GameManager.RestartARSession());
        yield return(new WaitForSeconds(0.5f));

        ARManager.SetPlaneManagerActive(true);
        SpawnARObjectPlacement();
    }
Пример #5
0
    public void BackToMainMenu()
    {
        DestroyGameSessionObjects();

        ARManager.SetPlanesInvisible(false);
        ARManager.SetPlanesActive(false);
        ARManager.SetPlaneManagerActive(false);

        MenuManager.instance.SpawnMenu(eMenus.MAIN_MENU);
        GameModeManager.instance.DestroyActiveGameMode();
    }
Пример #6
0
    private void OnDisable()
    {
        UIManager.onDrawModeButtonPressed     -= ChangeDrawState;
        UIManager.onBlockDisplayButtonPressed -= ChangeBlock;
        UIManager.onEnemyDisplayButtonPressed -= ChangeEnemy;

        if (worldZeroBlock != null)
        {
            Destroy(worldZeroBlock);
        }

        ARManager.SetPlanesInvisible(true);
        ARManager.SetPlanesActive(false);
        ARManager.SetPlaneManagerActive(false);
    }
Пример #7
0
    IEnumerator RestartLocalARSession()
    {
        yield return(new WaitForSeconds(0.1f));

        StartCoroutine(GameManager.RestartARSession());
        ChangeState(ePlacementState.PLANE_DETECTION);
        yield return(new WaitForSeconds(0.5f));

        ActivateClick();

        scaleSlider.value = defaultSliderValue;
        Destroy(spawnedPrefab);

        ARManager.SetPlaneManagerActive(true);
    }
Пример #8
0
    public void GoToMainMenu()
    {
        UIManager.onDrawModeButtonPressed     -= ChangeDrawState;
        UIManager.onBlockDisplayButtonPressed -= ChangeBlock;

        if (worldZeroBlock != null)
        {
            Destroy(worldZeroBlock);
        }

        ARManager.SetPlanesActive(false);
        ARManager.SetPlaneManagerActive(false);

        MenuManager.instance.SpawnMenu(eMenus.MAIN_MENU);
        GameModeManager.instance.DestroyActiveGameMode();
    }
Пример #9
0
    void ChangeState(ePlacementState newState)
    {
        //Exiting State
        if (placementState == ePlacementState.PLANE_DETECTION)
        {
            planeDetectionUI.SetActive(false);
        }
        else if (placementState == ePlacementState.SCALE_OBJECT)
        {
            if (newState != ePlacementState.FINISH)
            {
                scaleUI.SetActive(false);
            }
        }


        placementState = newState;


        if (placementState == ePlacementState.PLANE_DETECTION)
        {
            ARManager.SetPlaneManagerActive(true);
            planeDetectionUI.SetActive(true);
            curTimeSpentOnPlaneDetection = 0;
            instructionsText.text        = "Slowly pan your phone around your play area to discover surfaces";
        }
        else if (placementState == ePlacementState.OBJECT_PLACEMENT)
        {
            instructionsText.text = "Tap anywhere within the surface to spawn the " + gameObjectName;
        }
        else if (placementState == ePlacementState.SCALE_OBJECT)
        {
            scaleUI.SetActive(true);
            instructionsText.text = "Use the slider to adjust the size to fit your environment if neccesary";
        }
        else if (placementState == ePlacementState.FINISH)
        {
            FinishObjectPlacement();
        }
    }
Пример #10
0
 private void Start()
 {
     ARManager.SetPlaneManagerActive(false);
     //ARManager.SetPointCloudManagerActive(false);
 }
Пример #11
0
    void ChangeState(eTrashkitballState newState)
    {
        //Exiting State
        if (trashkitballState == eTrashkitballState.IN_PLAY)
        {
            if (newState != eTrashkitballState.GAME_OVER)
            {
                generalUI.SetActive(false);
            }
        }
        else if (trashkitballState == eTrashkitballState.GAME_OVER)
        {
            gameOverUI.SetActive(false);
        }

        trashkitballState = newState;

        //Entering State
        if (trashkitballState == eTrashkitballState.INIT)
        {
            ARManager.SetPlaneManagerActive(true);
            ARManager.SetPlanesInvisible(false);
            ARManager.TogglePlanePrefab(false);

            SpawnARObjectPlacement();
            trashCount            = 10;
            score                 = 0;
            currentDisplayedScore = 0;
            animatingScore        = false;
            scoreText.text        = "0";
            trashCountText.text   = trashCount.ToString();
        }
        else if (trashkitballState == eTrashkitballState.IN_PLAY)
        {
            //Deactivate any planes that may be above the trashcan
            var planes = ARManager.arPlaneManager.trackables;
            foreach (var p in planes)
            {
                if (p.transform.position.y > (spawnedTrashcan.transform.position.y + spawnedTrashcan.GetComponentInChildren <MeshRenderer>().bounds.size.y / 2))
                {
                    //ARDebug.Log("Turned off plane above trashcan", 5);
                    p.gameObject.SetActive(false);
                }
            }

            ARManager.SetPlaneManagerActive(false);
            ARManager.SetPlanesInvisible(true);

            generalUI.SetActive(true);

            //This is a stupid way to do this, use triggers in the animator and have them be able to call themselves of the Any state
            //canvasAnimator.Play("New State");
            canvasAnimator.SetTrigger("Play");

            StartCoroutine(SpawnTrashTimed(1.5f));
        }
        else if (trashkitballState == eTrashkitballState.RESETTING_AR)
        {
            DestroyGameSessionObjects();
            StartCoroutine(RestartLocalARSession());
        }
        else if (trashkitballState == eTrashkitballState.GAME_OVER)
        {
            gameOverUI.SetActive(true);
            toCloseUI.SetActive(false);
            goScoreText.text = score.ToString();

            canvasAnimator.SetTrigger("GameOver");
            SoundManager.instance.PlaySound(gameOver_sfx);
        }
    }