示例#1
0
    ///特定のオブジェクトの座標情報を保存し、停止させる
    void StartCounting()
    {
        Predicate <Rigidbody> rigidbodyPredicate =
            obj => !obj.IsSleeping() &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        waitingRigidbody  = Array.FindAll(transform.GetComponentsInChildren <Rigidbody>(), rigidbodyPredicate);
        rigidbodyVelocity = new RigidbodyVelocity[waitingRigidbody.Length];
        for (int i = 0; i < waitingRigidbody.Length; i++)
        {
            //速度、角度を保存
            rigidbodyVelocity[i] = new RigidbodyVelocity(waitingRigidbody[i]);
            waitingRigidbody[i].Sleep();
        }

        Predicate <MonoBehaviour> monoBehaviourPredicate =
            obj => obj.enabled && obj != this &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        waitingMonoBehaviour = Array.FindAll(
            transform.GetComponentsInChildren <MonoBehaviour>(),
            monoBehaviourPredicate);
        foreach (var monoBehaviour in waitingMonoBehaviour)
        {
            monoBehaviour.enabled = false;
        }
    }
示例#2
0
    /// <summary>
    /// 中断
    /// </summary>
    void Pause()
    {
        // Rigidbodyの停止
        // 子要素から、スリープ中でなく、IgnoreGameObjectsに含まれていないRigidbodyを抽出
        Predicate <Rigidbody> rigidbodyPredicate =
            obj => !obj.IsSleeping() &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        pausingRigidbodies  = Array.FindAll(transform.GetComponentsInChildren <Rigidbody>(), rigidbodyPredicate);
        rigidbodyVelocities = new RigidbodyVelocity[pausingRigidbodies.Length];
        for (int i = 0; i < pausingRigidbodies.Length; i++)
        {
            // 速度、角速度も保存しておく
            rigidbodyVelocities[i] = new RigidbodyVelocity(pausingRigidbodies[i]);
            pausingRigidbodies[i].Sleep();
        }

        // MonoBehaviourの停止
        // 子要素から、有効かつこのインスタンスでないもの、IgnoreGameObjectsに含まれていないMonoBehaviourを抽出
        Predicate <MonoBehaviour> monoBehaviourPredicate =
            obj => obj.enabled &&
            obj != this &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        pausingMonoBehaviours = Array.FindAll(transform.GetComponentsInChildren <MonoBehaviour>(), monoBehaviourPredicate);
        foreach (var monoBehaviour in pausingMonoBehaviours)
        {
            monoBehaviour.enabled = false;
        }
    }
示例#3
0
    void Pause()
    {
        switch (state)
        {
        case GameState.Game:
            state = GameState.Pause;
            for (int i = 0; i < pausingGameObjects.Length; i++)
            {
                pausingRigidbodies[i] = pausingGameObjects[i].GetComponent <Rigidbody>();
            }
            for (int i = 0; i < pausingRigidbodies.Length; i++)
            {
                rigidbodyVelocities[i]            = new RigidbodyVelocity(pausingRigidbodies[i]);
                pausingRigidbodies[i].isKinematic = true;
            }
            break;

        case GameState.Pause:
            state = GameState.Game;
            for (int i = 0; i < pausingRigidbodies.Length; i++)
            {
                pausingRigidbodies[i].isKinematic     = false;
                pausingRigidbodies[i].velocity        = rigidbodyVelocities[i].velocity;
                pausingRigidbodies[i].angularVelocity = rigidbodyVelocities[i].angularVelocity;
            }
            break;

        default:
            break;
        }
    }
示例#4
0
    /// <summary>
    /// 中断
    /// </summary>
    void Pause()
    {
        // Rigidbodyの停止
        // 子要素から、スリープ中でなく、IgnoreGameObjectsに含まれていないRigidbodyを抽出
        Predicate <Rigidbody> rigidbodyPredicate =
            obj => !obj.IsSleeping() &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        _pausingRigidbodies  = Array.FindAll(transform.GetComponentsInChildren <Rigidbody>(), rigidbodyPredicate);
        _rigidbodyVelocities = new RigidbodyVelocity[_pausingRigidbodies.Length];
        for (int i = 0; i < _pausingRigidbodies.Length; i++)
        {
            // 速度、角速度も保存しておく
            _rigidbodyVelocities[i] = new RigidbodyVelocity(_pausingRigidbodies[i]);
            _pausingRigidbodies[i].Sleep();
        }

        // MonoBehaviourの停止
        // 子要素から、有効かつこのインスタンスでないもの、IgnoreGameObjectsに含まれていないMonoBehaviourを抽出
        Predicate <MonoBehaviour> monoBehaviourPredicate =
            obj => obj.enabled &&
            obj != this &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        _pausingMonoBehaviours = Array.FindAll(transform.GetComponentsInChildren <MonoBehaviour>().Where(obj => obj.gameObject != this.gameObject).ToArray(), monoBehaviourPredicate);
        foreach (var monoBehaviour in _pausingMonoBehaviours)
        {
            monoBehaviour.enabled = false;
        }

        // ボリューム変更
        AudioManager.Instance.ChangeVolume(0.2f, 1f);
    }
        public void SetUp()
        {
            timeOverride = new TimeSettingOverride(0.02f, 0.3333333f, 1f, 0.03f);

            containingObject = new GameObject();
            subject          = containingObject.AddComponent <RigidbodyVelocity>();
            subjectRigidbody = containingObject.AddComponent <Rigidbody>();
        }
示例#6
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.tag == "Floor")
        {
            Debug.Log("GameOver");
            m_Restart.SetActive(true);
            //m_Restart.localPosition = new Vector3 (0.0f, -400.0f, 0.0f);
            m_GameOver.text = "GameOver";
            pausing         = true;

            Destroy(GameObject.Find("Left"));
            Destroy(GameObject.Find("Right"));

            // Rigidbodyの停止
            // 子要素から、スリープ中でなく、IgnoreGameObjectsに含まれていないRigidbodyを抽出
            Predicate <Rigidbody> rigidbodyPredicate =
                obj => !obj.IsSleeping() &&
                Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;
            pausingRigidbodies  = Array.FindAll(transform.GetComponentsInChildren <Rigidbody>(), rigidbodyPredicate);
            rigidbodyVelocities = new RigidbodyVelocity[pausingRigidbodies.Length];
            for (int i = 0; i < pausingRigidbodies.Length; i++)
            {
                // 速度、角速度も保存しておく
                rigidbodyVelocities[i] = new RigidbodyVelocity(pausingRigidbodies[i]);
                pausingRigidbodies[i].Sleep();
            }

            // MonoBehaviourの停止
            // 子要素から、有効かつこのインスタンスでないもの、IgnoreGameObjectsに含まれていないMonoBehaviourを抽出
            Predicate <MonoBehaviour> monoBehaviourPredicate =
                obj => obj.enabled &&
                obj != this &&
                Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;
            pausingMonoBehaviours = Array.FindAll(transform.GetComponentsInChildren <MonoBehaviour>(), monoBehaviourPredicate);
            foreach (var monoBehaviour in pausingMonoBehaviours)
            {
                monoBehaviour.enabled = false;
            }
        }
    }
示例#7
0
    //中断処理
    public void Pause(float time)
    {
        if (isPausing)
        {
            return;
        }
        isPausing = true;
        fadeTime  = time;
        this.time = 0.0f;

        bool hasNull = false;

        foreach (var obj in ignoreGameObjects)
        {
            if (obj == null)
            {
                hasNull = true;
                break;
            }
        }
        // nullを破棄する
        //if (ignoreGameObjects.Contains(null))
        if (hasNull)
        {
            var ignoreList = new List <GameObject>(ignoreGameObjects);
            ignoreList.RemoveAll(item => item == null);
            ignoreGameObjects = ignoreList.ToArray();
        }

        //Rigidbodyの停止
        //子要素から、スリープ中でなく、IgnoreGameObjectsに含まれていないRigidbodyを抽出
        Predicate <Rigidbody2D> rigidbodyPredicate =
            obj => !obj.IsSleeping() &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        pausingRigidbodies = Array.FindAll(
            (objectsWrapper
                ? objectsWrapper.GetComponentsInChildren <Rigidbody2D>()
                : Utility.GetComponentsInActiveScene <Rigidbody2D>()),
            rigidbodyPredicate);
        rigidbodyVelocities = new RigidbodyVelocity[pausingRigidbodies.Length];
        for (int i = 0; i < pausingRigidbodies.Length; ++i)
        {
            //速度と角速度の保存
            rigidbodyVelocities[i] = new RigidbodyVelocity(pausingRigidbodies[i]);
            //Rigidbodyの停止
            pausingRigidbodies[i].constraints = RigidbodyConstraints2D.FreezeAll;
            pausingRigidbodies[i].Sleep();
        }

        //MonoBehaviourの停止
        //子要素から、有効かつこのインスタンスでないもの、IgnoreGameObjectsに含まれていないMonoBehaviourを抽出
        Predicate <MonoBehaviour> monoBehaviourPredicate =
            obj => obj.enabled &&
            obj != this &&
            Array.FindIndex(ignoreGameObjects, gameObject =>
                            Array.FindIndex(gameObject.GetComponentsInChildren <Transform>(), child => child == obj.transform) >= 0) < 0;
        var debugMonoBehaviours = Utility.GetComponentsInActiveScene <MonoBehaviour>();

        pausingMonoBehaviours = Array.FindAll(
            (objectsWrapper
            ? objectsWrapper.GetComponentsInChildren <MonoBehaviour>()
            : Utility.GetComponentsInActiveScene <MonoBehaviour>()),
            monoBehaviourPredicate);
        foreach (var monoBehaviour in pausingMonoBehaviours)
        {
            //MonoBehaviourの停止
            monoBehaviour.enabled = false;
        }

        //Animatorの停止
        //子要素から、有効である、IgnoreGameObjectsに含まれていないAnimatorを抽出
        Predicate <Animator> animatorPredicate =
            obj => obj.enabled &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        pausingAnimators = Array.FindAll(
            (objectsWrapper
            ? objectsWrapper.GetComponentsInChildren <Animator>()
            : Utility.GetComponentsInActiveScene <Animator>()),
            animatorPredicate);
        animatorSpeeds = new float[pausingAnimators.Length];
        for (int i = 0; i < pausingAnimators.Length; ++i)
        {
            //速度の保存
            animatorSpeeds[i] = pausingAnimators[i].speed;
            //Animatorの停止
            pausingAnimators[i].speed = 0f;
        }

        //パーティクルの停止
        //子要素から、再生中である、IgnoreGameObjectsに含まれていないParticleSystemを抽出
        Predicate <ParticleSystem> particleSystemPredicate =
            obj => obj.isPlaying &&
            Array.FindIndex(ignoreGameObjects, gameObject => gameObject == obj.gameObject) < 0;

        pausingParticleSystems = Array.FindAll(
            (objectsWrapper
            ? objectsWrapper.GetComponentsInChildren <ParticleSystem>()
            : Utility.GetComponentsInActiveScene <ParticleSystem>()),
            particleSystemPredicate);
        particleEmittings = new bool[pausingParticleSystems.Length];
        for (int i = 0; i < pausingParticleSystems.Length; ++i)
        {
            //放出状態の保存
            particleEmittings[i] = pausingParticleSystems[i].isEmitting;
            //ParticleSystemの停止
            pausingParticleSystems[i].Pause();
        }
    }