Example #1
0
        private void Update()
        {
            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldShowDebugLog = syncSpawnedGlobalParams.ShouldShowDebugLog.Value;
                if (!shouldShowDebugLog)  // 消す
                {
                    if (hasShownDebugLog)
                    {
                        DebugLog.SetActive(false);
                        hasShownDebugLog = false;
                    }
                }
                else  // 表示する
                {
                    if (!hasShownDebugLog)
                    {
                        DebugLog.SetActive(true);
                        hasShownDebugLog = true;
                    }
                }
            }
        }
        public void OnInputClicked(InputClickedEventData eventData)
        {
            eventData.Use(); // イベントが使われたことを記録して、他の処理に受け取られるのを防ぐ

            if (shouldExistPrefab)
            {
                var prefabs = GameObject.FindGameObjectsWithTag(PrefabTag);
                foreach (var prefab in prefabs)
                {
                    var syncModelAccessor = prefab.GetComponent <DefaultSyncModelAccessor>();
                    if (syncModelAccessor != null)
                    {
                        var syncSpawnObject = (SyncSpawnedObject)syncModelAccessor.SyncModel;
                        // 磁石のOnDestroyを走らせる
                        UnityEngine.Object.DestroyImmediate(prefab);
                        this.spawnManager.Delete(syncSpawnObject);
                    }
                }

                shouldExistPrefab = false;
            }
            else
            {
                Vector3    position      = new Vector3(0, 0, 0f);
                Quaternion rotation      = Quaternion.identity;
                var        spawnedObject = new SyncSpawnedGlobalParams(); // 注意
                this.spawnManager.Spawn(
                    spawnedObject, position, rotation, spawnParentTransform.gameObject, PrefabTag, false);

                shouldExistPrefab = true;
            }
        }
Example #3
0
        // Update is called once per frame
        void Update()
        {
            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldGoAndBack = syncSpawnedGlobalParams.ShouldShowCompass3D.Value;
                if (shouldGoAndBack)  // z座標を固定する
                {
                    GameObject sharingStage = GameObject.Find("SharingStage");
                    transform.position =
                        sharingStage.transform.position +
                        sharingStage.transform.rotation *
                        new Vector3(0.3f * Mathf.Sin(Time.time / 3f) - 0.04f, -0.2f, 1.0f);

                    transform.rotation = sharingStage.transform.rotation *
                                         Quaternion.Euler(0, 0, -90);
                    //transform.rotation = Quaternion.identity;
                    //transform.rotation = Quaternion.Euler(
                    //    sharingStage.transform.rotation * new Vector3(0, 0, -90));

                    if (!hasGoneAndBack)
                    {
                        GameObject[] barMagnets = GameObject.FindGameObjectsWithTag("Bar Magnet");
                        if (gameObject == barMagnets[0])
                        {
                            MyHelper.MyDelayMethod(this, 2f, () =>
                            {
                                PlayAudioClip(ACMoving);
                            });
                            hasGoneAndBack = true;
                            isPlayingAudio = true;
                        }
                    }
                }
                else
                {
                    hasGoneAndBack = false;
                    if (isPlayingAudio)
                    {
                        StopAudioClip();
                        isPlayingAudio = false;
                    }
                }
            }
        }
Example #4
0
        public void OnInputClicked(InputClickedEventData eventData)
        {
            eventData.Use(); // イベントが使われたことを記録して、他の処理に受け取られるのを防ぐ

            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldShowCompass = syncSpawnedGlobalParams.ShouldShowCompass2D.Value;
                if (!shouldShowCompass)
                {
                    syncSpawnedGlobalParams.ShouldShowCompass2D.Value = true;

                    Vector3    position      = new Vector3(0, 0, 0f);
                    Quaternion rotation      = Quaternion.identity;
                    var        spawnedObject = new SyncSpawnedCompassPlacer2D();
                    this.spawnManager.Spawn(
                        spawnedObject, position, rotation, spawnParentTransform.gameObject,
                        "CompassPlacer2D", false);
                }
                else
                {
                    syncSpawnedGlobalParams.ShouldShowCompass2D.Value = false;

                    var prefabs = GameObject.FindGameObjectsWithTag(PrefabTag);
                    foreach (var prefab in prefabs)
                    {
                        var syncModelAccessor = prefab.GetComponent <DefaultSyncModelAccessor>();
                        if (syncModelAccessor != null)
                        {
                            var syncSpawnObject = (SyncSpawnedObject)syncModelAccessor.SyncModel;
                            // 磁石のOnDestroyを走らせる
                            UnityEngine.Object.DestroyImmediate(prefab);
                            this.spawnManager.Delete(syncSpawnObject);
                        }
                    }
                }
            }
        }
        public void ToggleCompass3D()
        {
            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldShowCompass = syncSpawnedGlobalParams.ShouldShowCompass3D.Value;
                if (!shouldShowCompass)
                {
                    syncSpawnedGlobalParams.ShouldShowCompass3D.Value = true;

                    Vector3    position      = new Vector3(0, 0, 0f);
                    Quaternion rotation      = Quaternion.identity;
                    var        spawnedObject = new SyncSpawnedCompassPlacer3D(); // 要編集
                    this.spawnManager.Spawn(
                        spawnedObject, position, rotation, spawnParentTransform.gameObject,
                        "CompassPlacer3D", false);  // 要編集
                }
                else
                {
                    syncSpawnedGlobalParams.ShouldShowCompass3D.Value = false;

                    var prefabs = GameObject.FindGameObjectsWithTag(PrefabTag);
                    foreach (var prefab in prefabs)
                    {
                        var syncModelAccessor = prefab.GetComponent <DefaultSyncModelAccessor>();
                        if (syncModelAccessor != null)
                        {
                            var syncSpawnObject = (SyncSpawnedObject)syncModelAccessor.SyncModel;
                            // 磁石のOnDestroyを走らせる
                            UnityEngine.Object.DestroyImmediate(prefab);
                            this.spawnManager.Delete(syncSpawnObject);
                        }
                    }
                }
            }

            return;
        }
Example #6
0
        // Update is called once per frame
        void Update()
        {
            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldHoldZPosition = syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value;
                if (shouldHoldZPosition)  // z座標を固定する
                {
                    transform.localPosition = new Vector3(
                        transform.localPosition.x,
                        transform.localPosition.y,
                        1.5f);
                    transform.localRotation = Quaternion.Euler(0, 0, -90);
                }
            }
        }
        public void ToggleHoldBarMagnetZPosition( )
        {
            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldHoldBarMagnet = syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value;
                if (!shouldHoldBarMagnet)
                {
                    syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value = true;
                }
                else
                {
                    syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value = false;
                }
            }
            return;
        }
        public void OnInputClicked(InputClickedEventData eventData)
        {
            eventData.Use(); // イベントが使われたことを記録して、他の処理に受け取られるのを防ぐ

            GameObject GlobalParams = GameObject.FindGameObjectWithTag("Global Params");

            if (GlobalParams != null)
            {
                SyncSpawnedGlobalParams syncSpawnedGlobalParams =
                    (SyncSpawnedGlobalParams)GlobalParams.
                    GetComponent <DefaultSyncModelAccessor>().SyncModel;
                bool shouldHoldBarMagnet = syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value;
                if (!shouldHoldBarMagnet)
                {
                    syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value = true;
                }
                else
                {
                    syncSpawnedGlobalParams.ShouldHoldBarMagnetZPosition.Value = false;
                }
            }
        }