Exemple #1
0
    // 自オブジェクトをリスポーン
    void RespawnMyObject()
    {
        UnityEngine.Debug.Log("RespawnMyObject myObject=" + myObject);
        List <MultiSpeakerVoice.SpeakerObjectInfo> infos = null;

        if (null != myObject)
        {
            // スピーカーオブジェクトの破棄
            var wrapper = myObject.GetComponent <MultiSpeakerVoice>();
            wrapper.DestroySpeakerObject();
            infos = wrapper.GetSpeakerObjectInfosAsClone();

            // 自オブジェクトを破棄
            MonobitNetwork.Destroy(myObject);
        }

        // 自オブジェクトをスポーン
        SpawnMyObject();
        if (null != myObject)
        {
            // スピーカーオブジェクトのスポーン
            var wrapper = myObject.GetComponent <MultiSpeakerVoice>();
            wrapper.SpawnSpeakerObject(infos);
        }
    }
 // 自オブジェクトをリスポーン
 void RespawnMyObject()
 {
     UnityEngine.Debug.Log("RespawnMyObject myObject=" + myObject);
     if (null != myObject)
     {
         MonobitNetwork.Destroy(myObject);
     }
     SpawnMyObject();
 }
 /// <summary>
 /// スピーカーオブジェクトの廃棄
 /// </summary>
 public void DestroySpeakerObject()
 {
     for (int i = 0; i < SpeakerObjectInfos.Count; ++i)
     {
         MonobitNetwork.Destroy(SpeakerObjectInfos[i].speakerObject);
         SpeakerObjectInfos[i].speakerObject = null;
         SpeakerObjectInfos[i].voice         = null;
     }
 }
Exemple #4
0
    void Died()
    {
        AudioSource.PlayClipAtPoint(this.deathSeClip, this.transform.position);
        this.status.died = true;


        if (this.gameObject.CompareTag("Boss"))
        {
            this.gameRuleCtrl.GameClear();
        }
        if (MonobitNetwork.isHost)
        {
            this.DropItem();
            MonobitNetwork.Destroy(this.gameObject);
        }
    }
Exemple #5
0
        /**
         * @brief   更新関数.
         */
        void Update()
        {
            // ゲーム中の処理
            if (isGameStart && !isGameEnd)
            {
                // まだ自分のキャラクタのspawnが終わっていない状態であれば、自身のキャラクタをspawnする
                if (!isSpawnMyChara)
                {
                    OnGameStart();
                }

                // 自身のキャラクタ位置の退避
                if (myObject != null)
                {
                    myPosition = myObject.transform.position;
                    myRotation = myObject.transform.rotation;
                }

                // ルーム名の退避
                if (MonobitNetwork.room != null)
                {
                    reconnectRoomName = MonobitNetwork.room.name;
                }

                // ホストの場合の処理
                if (MonobitNetwork.isHost)
                {
                    // アイテムに接近したら、アイテム取得処理を実行する
                    if (gameItemRakeupCount < gameItemLimit)
                    {
                        for (int index = itemObject.Count - 1; index >= 0; --index)
                        {
                            foreach (SD_Unitychan_PC playerObject in s_PlayerObject)
                            {
                                if ((playerObject.transform.position - itemObject[index].transform.position).magnitude < 1.0f)
                                {
                                    // そのオブジェクトを削除する
                                    MonobitNetwork.Destroy(itemObject[index]);
                                    itemObject.Remove(itemObject[index]);

                                    // 自身のスコア情報を加算するRPC処理を実行する
                                    monobitView.RPC("OnUpdateScore", MonobitTargets.All, playerObject.GetPlayerID(), playerObject.MyScore + 100);
                                    gameItemRakeupCount++;
                                }
                            }
                        }
                    }
                    else
                    {
                        // ゲーム終了メッセージを送信
                        monobitView.RPC("OnGameEnd", MonobitTargets.All, null);
                    }

                    // 制限時間の減少
                    if (gameTimeLimit > 0)
                    {
                        gameTimeLimit--;
                    }
                    else
                    {
                        // ゲーム終了メッセージを送信
                        monobitView.RPC("OnGameEnd", MonobitTargets.All, null);
                    }

                    // 個数制限&時間制限のタイミングで、ゲームシーン上にオブジェクトを配置
                    if ((gameItemIsPut < gameItemLimit) && (gameTimeLimit % 10 == 0))
                    {
                        // ある程度ランダムな位置・姿勢でプレイヤーを配置する
                        Vector3 position = Vector3.zero;
                        position.x = UnityEngine.Random.Range(-10.0f, 10.0f);
                        position.z = UnityEngine.Random.Range(-10.0f, 10.0f);
                        Quaternion rotation = Quaternion.AngleAxis(UnityEngine.Random.Range(-180.0f, 180.0f), Vector3.up);

                        // オブジェクトの配置(他クライアントにも同時にInstantiateする)
                        MonobitNetwork.InstantiateSceneObject("item", position, rotation, 0, null);

                        // ゲームオブジェクト出現個数を加算
                        gameItemIsPut++;
                    }

                    // 制限時間をRPCで送信
                    monobitView.RPC("TickCount", MonobitTargets.Others, gameTimeLimit);
                }
            }
        }
    // Update is called once per frame
    public void Update()
    {
        if (monobitView.isOwner)
        {
            // キャラクタの移動&アニメーション切り替え
            if (Input.GetKey("up"))
            {
                gameObject.transform.position += gameObject.transform.forward * 0.1f;
                animator.SetInteger(animId, 1);
            }
            else
            {
                animator.SetInteger(animId, 0);
            }
            if (Input.GetKey("right"))
            {
                gameObject.transform.Rotate(0, 2.0f, 0);
            }
            if (Input.GetKey("left"))
            {
                gameObject.transform.Rotate(0, -2.0f, 0);
            }
            if (Input.GetKeyDown("z"))
            {
                MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0);
            }
            if (Input.GetKeyDown("s"))
            {
                MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0, null, true, false, true);
            }
            if (Input.GetKeyDown("e"))
            {
                MonobitNetwork.Instantiate("Cube", transform.position, transform.rotation, 0, null, true, false, false);
            }
            if (Input.GetKeyDown("d"))
            {
                UnityEngine.Debug.Log("Destroy Cube Start");
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    MonobitNetwork.Destroy(go);
                    if (!view.enabled)
                    {
                        UnityEngine.Debug.Log("Destroy Cube: " + view);
                    }
                }
                UnityEngine.Debug.Log("Destroy Cube End");
            }
            if (Input.GetKeyDown("r"))
            {
                UnityEngine.Debug.Log("RequestOwnership Cube Start");
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    view.RequestOwnership();
                    UnityEngine.Debug.Log("RequestOwnership Cube: " + view);
                }
                UnityEngine.Debug.Log("RequestOwnership Cube End");
            }
            if (Input.GetKeyDown("t"))
            {
                UnityEngine.Debug.Log("TransferOwnership Cube Start");
                int playerId = MonobitNetwork.player.ID;
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    view.TransferOwnership(playerId);
                    UnityEngine.Debug.Log("TransferOwnership Cube: " + view);
                }
                UnityEngine.Debug.Log("TransferOwnership Cube End");
            }
            if (Input.GetKeyDown("i"))
            {
                UnityEngine.Debug.Log("Change IsDontDestroyOnRoom Cube Start");
                foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                {
                    MonobitView view = go.GetComponent <MonobitView>();
                    if (null == view)
                    {
                        continue;
                    }
                    if ("Cube(Clone)" != go.name)
                    {
                        continue;
                    }

                    bool isDontDestroyOnRoom = view.isDontDestroyOnRoom;
                    view.isDontDestroyOnRoom = !isDontDestroyOnRoom;
                    if (isDontDestroyOnRoom != view.isDontDestroyOnRoom)
                    {
                        UnityEngine.Debug.Log("Change IsDontDestroyOnRoom Cube: " + view + " " + isDontDestroyOnRoom + " -> " + view.isDontDestroyOnRoom);
                    }
                }
                UnityEngine.Debug.Log("Change IsDontDestroyOnRoom Cube End");
            }
            if (Input.GetKeyDown("0"))
            {
                serializeBytes[0] = 0;
            }
            if (Input.GetKeyDown("1"))
            {
                serializeBytes[0] = 1;
            }
        }
    }