示例#1
0
        public override void SetUpPlayArea(BAnchorInformation[] bAnchorInformation)
        {
            // TODO: Wait for some frames ?


            if (ARE_EQUAL(bAnchorInformation.Length, 2))
            {
                PlayAreaState = EPlayAreaState.SETTING_ANCHORS;

                // Spawn BAnchors
                for (int i = 0; i < 2; i++)
                {
                    PlayAreaBAnchor playAreaBAnchor = AddNewChildBAnchor(false);
                    if (IS_NOT_NULL(playAreaBAnchor))
                    {
                        playAreaBAnchor.gameObject.name += "_" + (i + 1);
                        playAreaBAnchor.SetTransformedPosition(bAnchorInformation[i].TransformedPosition);
                        playAreaBAnchor.SetTransformedRotation(bAnchorInformation[i].TransformedRotation);
                    }
                }

                // Finalize
                setAnchorsCount = 2;
                SetExtentPoints();
                DrawPlayAreaExtensions();
                FinalizePlayAreaSetup();
            }
        }
示例#2
0
        protected virtual PlayAreaBAnchor AddNewChildBAnchor(bool directlyStartPlacing = true)
        {
            if (IS_NOT_NULL(playAreaBAnchorPrefab) &&
                IS_NULL(CurrentPlayAreaBAnchorBeingPlaced))
            {
                PlayAreaBAnchor spawnedPlayAreaBAnchor = Instantiate(playAreaBAnchorPrefab);
                if (IS_NOT_NULL(spawnedPlayAreaBAnchor))
                {
                    spawnedPlayAreaBAnchor.transform.parent = transform;
                    PlayAreaBAnchors.Add(spawnedPlayAreaBAnchor);
                    LogConsole("Adding new play area BAnchor : " + PlayAreaBAnchors.Count);

                    spawnedPlayAreaBAnchor.StartedPlacing += On_SpawnedPlayAreaBAnchor_StartedPlacing;
                    spawnedPlayAreaBAnchor.EndedPlacing   += On_SpawnedPlayAreaBAnchor_EndedPlacing;

                    if (directlyStartPlacing)
                    {
                        spawnedPlayAreaBAnchor.OnStartPlacing();
                    }

                    return(spawnedPlayAreaBAnchor);
                }
            }
            return(null);
        }
示例#3
0
        private void StartSettingFirstAnchor()
        {
            PlayAreaBAnchor playAreaBAnchor = AddNewChildBAnchor();

            if (IS_NOT_NULL(playAreaBAnchor))
            {
                playAreaBAnchor.gameObject.name += "_1";
            }
        }
示例#4
0
 protected virtual void On_SpawnedPlayAreaBAnchor_StartedPlacing(PlayAreaBAnchor playAreaBAnchor)
 {
     if (IS_NOT_NULL(playAreaBAnchor) &&
         IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor) &&
         IS_NULL(CurrentPlayAreaBAnchorBeingPlaced))
     {
         CurrentPlayAreaBAnchorBeingPlaced = playAreaBAnchor;
     }
 }
示例#5
0
        private void On_BAnchorCursorPlacer_EndedPlacing(BAnchor bAnchor)
        {
            PlayAreaBAnchor playAreaBAnchor = (PlayAreaBAnchor)bAnchor;

            if (IS_NOT_NULL(playAreaBAnchor) &&
                (ARE_EQUAL(playAreaBAnchor, this)))
            {
                InvokeEventIfBound(EndedPlacing, this);
            }
        }
示例#6
0
 protected virtual void On_SpawnedPlayAreaBAnchor_EndedPlacing(PlayAreaBAnchor playAreaBAnchor)
 {
     if (IS_NOT_NULL(playAreaBAnchor) &&
         IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor) &&
         ARE_EQUAL(CurrentPlayAreaBAnchorBeingPlaced, playAreaBAnchor))
     {
         int index = PlayAreaBAnchors.IndexOf(playAreaBAnchor);
         InvokeEventIfBound(NewPlayAreaBAnchorSet, playAreaBAnchor, index);
         CurrentPlayAreaBAnchorBeingPlaced = null;
     }
 }
示例#7
0
        private void StartSettingSecondAnchor()
        {
            PlayAreaBAnchor playAreaBAnchor = AddNewChildBAnchor();

            if (IS_NOT_NULL(playAreaBAnchor) &&
                PlayAreaBAnchors.Count > 0 &&
                IS_NOT_NULL(PlayAreaBAnchors[0]))
            {
                playAreaBAnchor.gameObject.name += "_2";
                playAreaBAnchor.DisablePlacementRotation();
                playAreaBAnchor.transform.rotation = PlayAreaBAnchors[0].transform.rotation;
            }
        }
示例#8
0
        private IEnumerator SetTestPlayAreaCoroutine()
        {
            ARManager.Instance.SetupPlayArea();

            yield return(new WaitForEndOfFrame());

            ARCursor.Instance.transform.position = new Vector3(0.0f, 0.0f, 1.0f);
            PlayAreaBAnchor playAreaBAnchor = FindObjectOfType <PlayAreaBAnchor>();

            if (IS_NOT_NULL(playAreaBAnchor))
            {
                playAreaBAnchor.EndPlacing();
            }

            yield return(new WaitForEndOfFrame());

            ARCursor.Instance.transform.position = new Vector3(3.5f, 0.0f, 8.6f);
        }
示例#9
0
        protected virtual bool RemoveChildBAnchor(PlayAreaBAnchor playAreaBAnchor)
        {
            if (IS_NOT_NULL(playAreaBAnchor))
            {
                if (IS_VALUE_CONTAINED(PlayAreaBAnchors, playAreaBAnchor))
                {
                    playAreaBAnchor.StartedPlacing -= On_SpawnedPlayAreaBAnchor_StartedPlacing;
                    playAreaBAnchor.EndedPlacing   -= On_SpawnedPlayAreaBAnchor_EndedPlacing;

                    PlayAreaBAnchors.Remove(playAreaBAnchor);
                    if (CurrentPlayAreaBAnchorBeingPlaced == playAreaBAnchor)
                    {
                        CurrentPlayAreaBAnchorBeingPlaced = null;
                    }
                    Destroy(playAreaBAnchor.gameObject);
                    return(true);
                }
                LogConsoleWarning("Couldn't remove the given PlayAreaBAnchor : " + playAreaBAnchor.gameObject.name);
            }
            return(false);
        }
示例#10
0
        protected override void On_SpawnedPlayAreaBAnchor_EndedPlacing(PlayAreaBAnchor playAreaBAnchor)
        {
            base.On_SpawnedPlayAreaBAnchor_EndedPlacing(playAreaBAnchor);

            switch (setAnchorsCount)
            {
            case 0:
                setAnchorsCount = 1;
                LogConsole("First anchor set. Setting second anchor...");
                StartSettingSecondAnchor();
                break;

            case 1:
                setAnchorsCount = 2;
                LogConsole("Second anchor set. Finalizing setup.");
                FinalizePlayAreaSetup();
                break;

            default:
                LogConsoleWarning("Play Area already set up !");
                break;
            }
        }
示例#11
0
        protected override void OnValidate()
        {
            base.OnValidate();

            if (CanValidate() == false)
            {
                return;
            }

            if (myLineRenderer == null)
            {
                myLineRenderer = GetComponent <LineRenderer>();
                if (myLineRenderer)
                {
                    myLineRenderer.SetPositions(new Vector3[0]);
                }
            }

            if (playAreaBAnchorPrefab == null)
            {
                playAreaBAnchorPrefab = Resources.Load <PlayAreaBAnchor>(BConsts.PATH_AR_PlayAreaBAnchor);
            }
        }
示例#12
0
 protected override void On_SpawnedPlayAreaBAnchor_StartedPlacing(PlayAreaBAnchor playAreaBAnchor)
 {
     base.On_SpawnedPlayAreaBAnchor_StartedPlacing(playAreaBAnchor);
 }