Ejemplo n.º 1
0
    public static void FindMark()
    {
        Debug.LogFormat("Find Mark");
        if (Selection.objects.Count() == 0)
        {
            Debug.LogFormat("No objects selected");
        }
        Debug.LogFormat("Selection.objects[0] = {0}", Selection.objects[0]);

        if (Selection.objects[0] is Mark)
        {
            Selection.objects = MonoBehaviour.FindObjectsOfType <Transform>().Where(t => t.Mentioned(Selection.objects[0] as Mark)).ToArray();

            if (Selection.objects.Length > 0)
            {
                EditorGUIUtility.PingObject(Selection.objects[0]);
            }
            DebugManager.LogFormat("Selection.objects = {0}", Selection.objects.ExtToString());
        }
    }
Ejemplo n.º 2
0
        internal static void DestroySceneObjects()
        {
            NetworkedObject[] netObjects = MonoBehaviour.FindObjectsOfType <NetworkedObject>();

            for (int i = 0; i < netObjects.Length; i++)
            {
                if (netObjects[i].IsSceneObject == null || netObjects[i].IsSceneObject.Value == true)
                {
                    if (customDestroyHandlers.ContainsKey(netObjects[i].PrefabHash))
                    {
                        customDestroyHandlers[netObjects[i].PrefabHash](netObjects[i]);
                        SpawnManager.OnDestroyObject(netObjects[i].NetworkId, false);
                    }
                    else
                    {
                        MonoBehaviour.Destroy(netObjects[i].gameObject);
                    }
                }
            }
        }
        internal static void DestroyNonSceneObjects()
        {
            var networkObjects = MonoBehaviour.FindObjectsOfType <NetworkObject>();

            for (int i = 0; i < networkObjects.Length; i++)
            {
                if (networkObjects[i].IsSceneObject != null && networkObjects[i].IsSceneObject.Value == false)
                {
                    if (CustomDestroyHandlers.ContainsKey(networkObjects[i].PrefabHash))
                    {
                        CustomDestroyHandlers[networkObjects[i].PrefabHash](networkObjects[i]);
                        OnDestroyObject(networkObjects[i].NetworkObjectId, false);
                    }
                    else
                    {
                        MonoBehaviour.Destroy(networkObjects[i].gameObject);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 static void Update()
 {
     EditorPlusHistorySceneObjects[] objs = MonoBehaviour.FindObjectsOfType <EditorPlusHistorySceneObjects>();
     if (objs.Length > 0)
     {
         foreach (EditorPlusHistorySceneObjects ob in objs)
         {
             MonoBehaviour.DestroyImmediate(ob.gameObject);
         }
         EditorApplication.SaveScene();
     }
     if (Scenes.Count > 0)
     {
         EditorApplication.OpenScene(Scenes[0]);
         Scenes.RemoveAt(0);
     }
     else
     {
         EditorApplication.update -= Update;
     }
 }
Ejemplo n.º 5
0
        public static TDScene LoadScene()
        {
            TDCamera camera = new TDCamera(Camera.main);

            List <TDSphere> spheres = new List <TDSphere>();

            TDSceneSphere[] sceneSpheres = MonoBehaviour.FindObjectsOfType <TDSceneSphere>();

            foreach (TDSceneSphere sceneSphere in sceneSpheres)
            {
                spheres.Add(new TDSphere(sceneSphere.transform.position,
                                         new Unity.Mathematics.float3(sceneSphere.albedo.r, sceneSphere.albedo.g, sceneSphere.albedo.b),
                                         sceneSphere.emissionIntensity * new Unity.Mathematics.float3(sceneSphere.emission.r, sceneSphere.emission.g, sceneSphere.emission.b),
                                         sceneSphere.transform.lossyScale.x * 0.5f,
                                         TDLoader.GetMaterialIndex(sceneSphere.material),
                                         sceneSphere.fuzz,
                                         sceneSphere.refractiveIndex));
            }

            return(new TDScene(camera, spheres));
        }
Ejemplo n.º 6
0
    public override void Enter()
    {
        goalAreas = MonoBehaviour.FindObjectsOfType <GoalArea>();
        ai        = MonoBehaviour.FindObjectOfType <AirHockeyAI>();
        player    = MonoBehaviour.FindObjectOfType <PadController>();

        foreach (GoalArea area in goalAreas)
        {
            // ゴールしたときの処理を登録
            area.OnGoaled = (type) =>
            {
                puck.SetActive(false);
                ai.SetActiveOperation(false);
                player.SetActiveOperation(false);

                // 塗られた色の割合を求め,スコアに適用する
                float ratio = DynamicPaintManager.Instance.ComputeColorRatio(type);
                ScoreStore.Instance.IncrementPoint(type, ratio);
            };
        }

        // スコアが更新されたときの処理を登録
        inGameUiController.OnScoreUpdated = () =>
        {
            // 現在のゲームをリセットする
            if (ScoreStore.Instance.Round < MaxRound)
            {
                Reset();
            }
            // 最大ラウンドまでしたら,ゲーム終了
            else
            {
                isGameFinished = true;
            }
        };

        ai.Initialize(new HS_Normal());
        inGameUiController.PlayView();
        Reset();
    }
Ejemplo n.º 7
0
    /// パーティクルの生成
    public static Module AddModule(int type, int first, int second, int third, int moduleId)
    {
        // プレハブを取得
        Prefab = Resources.Load <GameObject>("Prefabs/Module");
        //// プレハブからインスタンスを生成
        /// インスタンスを生成してスクリプトを返す.
        GameObject g   = Module.Instantiate(Prefab, Vector3.zero, Quaternion.identity) as GameObject;
        Module     obj = g.GetComponent <Module>();

        if (obj != null)
        {
            obj.Type       = type;
            obj.Object1Id  = first;
            obj.Object2Id  = second;
            obj.Object3Id  = third;
            obj.Id         = moduleId;
            obj.Active     = true;
            obj.parent     = g;
            obj.ModuleName = GetModuleNameByType(type);
            AppMgr.mds     = MonoBehaviour.FindObjectsOfType <Module>();

            //もし余分なログがある場合には   余分なログは消す.
            if (LastLog != LogLength)
            {
                DeleteNonactiveLog();
            }
            //モジュールのログを作成
            Prefab = Resources.Load <GameObject>("Prefabs/GameLog");
            GetLogFolder();
            GameObject LogObj = MonoBehaviour.Instantiate <GameObject>(Prefab, Vector3.zero, Quaternion.identity, LogFolder.transform);
            Log        lg     = LogObj.GetComponent <Log>();
            lg.MakeModuleLog(obj);
            //ログをlogsに追加
            AddLog(lg);
            obj.GameLog = LogObj;
        }
        return(obj);
    }
Ejemplo n.º 8
0
 /// <summary>
 /// Helper method: Resets the game
 /// </summary>
 /// <param name="customIndex">Which player starts off.</param>
 private static void ResetGame(int customIndex)
 {
     NodeObject.ResetInteractions();
     TestManager.ins.ResetVictoryText();
     if (savedBoard != null)
     {
         test_OriginalBoard.boardArr = savedBoard;
     }
     savedBoard = null;
     if (TestManager.ins.allPlayers.Count != 0)
     {
         TestManager.ins.allPlayers.Clear();
     }
     foreach (var item in MonoBehaviour.FindObjectsOfType <UserModel>())
     {
         MonoBehaviour.Destroy(item.gameObject);
     }
     foreach (var item in MonoBehaviour.FindObjectsOfType <PieceObject>())
     {
         MonoBehaviour.Destroy(item.gameObject);
     }
     currPlayerIndex = customIndex;
 }
Ejemplo n.º 9
0
    public static Rect RectSize(RectTransform img)
    {
        Vector2 sizeDelta = img.sizeDelta;

        Canvas[]  canvasX = MonoBehaviour.FindObjectsOfType <Canvas>();
        Canvas    canvas  = MonoBehaviour.FindObjectOfType <Canvas>();
        Transform xBase   = img.transform.parent;

        while (xBase != null)
        {
            Canvas C = xBase.GetComponent <Canvas>();
            if (C != null)
            {
                canvas = C;
            }
            xBase = xBase.parent;
        }

        Vector3[] V = new Vector3[4];
        img.GetWorldCorners(V);

        return(new Rect(V[1].x, 240 - V[1].y, sizeDelta.x * canvas.scaleFactor, sizeDelta.y * canvas.scaleFactor));
    }
Ejemplo n.º 10
0
        private static void OnSceneUnload(AsyncOperation operation)
        {
            isSwitching = false;
            if (NetworkingManager.singleton.isServer)
            {
                SpawnManager.MarkSceneObjects();

                NetworkedObject[] networkedObjects = MonoBehaviour.FindObjectsOfType <NetworkedObject>();
                for (int i = 0; i < networkedObjects.Length; i++)
                {
                    if (!networkedObjects[i].isSpawned && (networkedObjects[i].sceneObject == null || networkedObjects[i].sceneObject == true))
                    {
                        networkedObjects[i].Spawn();
                    }
                }

                //SpawnManager.FlushSceneObjects();
            }
            else
            {
                SpawnManager.DestroySceneObjects();
            }
        }
Ejemplo n.º 11
0
    // 启动服务器
    public void StartServer(string levelName)
    {
        foreach (GameObject go in MonoBehaviour.FindObjectsOfType(typeof(GameObject)))
        {
            go.SendMessage("OnTryingToStartServer", connectPort, SendMessageOptions.DontRequireReceiver);
        }
        Network.InitializeSecurity();
        if (usePassword)
        {
            Network.incomingPassword = password;
        }

        // 初始化服务器
        bool useNat = !ForceUseNat ? !Network.HavePublicAddress() : true;

        Network.InitializeServer(maxConnections, connectPort, useNat);
        // 注册主机
        MasterServer.RegisterHost(gameType, serverName, serverDescription);

        Network.RemoveRPCsInGroup(0);
        Network.RemoveRPCsInGroup(1);
        networkView.RPC("LoadMap", RPCMode.AllBuffered, levelName, lastLevelPrefix + 1);
    }
Ejemplo n.º 12
0
 public void DestroyMenuOnUI()
 {
     GameObject[] go = MonoBehaviour.FindObjectsOfType <GameObject>();
     for (int i = 0; i < go.Length; i++)
     {
         if (go[i].name == "ButtonMenuOff(Clone)" ||
             go[i].name == "ButtonAddPoint(Clone)" ||
             go[i].name == "ButtonAddMidPoint(Clone)" ||
             go[i].name == "ButtonAddLine(Clone)" ||
             go[i].name == "ButtonAddCircle(Clone)" ||
             go[i].name == "ButtonPointOnPoint(Clone)" ||
             go[i].name == "ButtonPointOnLine(Clone)" ||
             go[i].name == "ButtonPointOnCircle(Clone)" ||
             go[i].name == "ButtonIntersection(Clone)" ||
             go[i].name == "ButtonIsom(Clone)" ||
             go[i].name == "ButtonPerp(Clone)" ||
             go[i].name == "ButtonPara(Clone)" ||
             go[i].name == "ButtonAngle(Clone)" ||
             go[i].name == "ButtonBisector(Clone)" ||
             go[i].name == "ButtonTangentL2C(Clone)" ||
             go[i].name == "ButtonTangentC2C(Clone)" ||
             go[i].name == "ButtonFixPoint(Clone)" ||
             go[i].name == "ButtonDeletePoint(Clone)" ||
             go[i].name == "ButtonDeleteAll(Clone)" ||
             go[i].name == "ButtonUndo(Clone)" ||
             go[i].name == "ButtonRedo(Clone)" ||
             go[i].name == "ButtonShowLogs(Clone)" ||
             go[i].name == "ButtonSave(Clone)" ||
             go[i].name == "ButtonOpen(Clone)" ||
             go[i].name == "ButtonSave2TeX(Clone)" ||
             go[i].name == "ButtonQuit(Clone)"
             )
         {
             Destroy(go[i]);
         }
     }
 }
Ejemplo n.º 13
0
 void ReplaceBombInfo()
 {
     MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();
     foreach (MonoBehaviour s in scripts)
     {
         IEnumerable <FieldInfo> fields = s.GetType().GetFields();
         foreach (FieldInfo f in fields)
         {
             if (f.FieldType.Equals(typeof(KMBombInfo)))
             {
                 KMBombInfo component = (KMBombInfo)f.GetValue(s);
                 component.TimeHandler                 += new KMBombInfo.GetTimeHandler(fakeInfo.GetTime);
                 component.FormattedTimeHandler        += new KMBombInfo.GetFormattedTimeHandler(fakeInfo.GetFormattedTime);
                 component.StrikesHandler              += new KMBombInfo.GetStrikesHandler(fakeInfo.GetStrikes);
                 component.ModuleNamesHandler          += new KMBombInfo.GetModuleNamesHandler(fakeInfo.GetModuleNames);
                 component.SolvableModuleNamesHandler  += new KMBombInfo.GetSolvableModuleNamesHandler(fakeInfo.GetSolvableModuleNames);
                 component.SolvedModuleNamesHandler    += new KMBombInfo.GetSolvedModuleNamesHandler(fakeInfo.GetSolvedModuleNames);
                 component.WidgetQueryResponsesHandler += new KMBombInfo.GetWidgetQueryResponsesHandler(fakeInfo.GetWidgetQueryResponses);
                 component.IsBombPresentHandler        += new KMBombInfo.KMIsBombPresent(fakeInfo.IsBombPresent);
                 continue;
             }
             if (f.FieldType.Equals(typeof(KMGameInfo)))
             {
                 KMGameInfo component = (KMGameInfo)f.GetValue(s);
                 component.OnLightsChange += new KMGameInfo.KMLightsChangeDelegate(fakeInfo.OnLights);
                 //component.OnAlarmClockChange += new KMGameInfo.KMAlarmClockChangeDelegate(fakeInfo.OnAlarm);
                 continue;
             }
             if (f.FieldType.Equals(typeof(KMGameCommands)))
             {
                 KMGameCommands component = (KMGameCommands)f.GetValue(s);
                 component.OnCauseStrike += new KMGameCommands.KMCauseStrikeDelegate(fakeInfo.HandleStrike);
                 continue;
             }
         }
     }
 }
Ejemplo n.º 14
0
        public static T[] FindAll <T> (bool includeInactive) where T : Component
        {
            if (includeInactive)
            {
                UnityEngine.Object[] tempList = Resources.FindObjectsOfTypeAll(typeof(T));
                List <T>             realList = new List <T> ();

                foreach (UnityEngine.Object obj in tempList)
                {
                    if (obj is T)
                    {
                        if (obj.hideFlags == HideFlags.None)
                        {
                            realList.Add((T)obj);
                        }
                    }
                }
                return(realList.ToArray());
            }
            else
            {
                return((T[])MonoBehaviour.FindObjectsOfType(typeof(T)));
            }
        }
Ejemplo n.º 15
0
        private static void OnSceneUnloadClient(Guid switchSceneGuid, Stream objectStream)
        {
            if (NetworkingManager.Singleton.NetworkConfig.UsePrefabSync)
            {
                SpawnManager.DestroySceneObjects();

                using (PooledBitReader reader = PooledBitReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject = reader.ReadBool();
                        ulong networkId      = reader.ReadUInt64Packed();
                        ulong owner          = reader.ReadUInt64Packed();

                        ulong prefabHash = reader.ReadUInt64Packed();

                        bool destroyWithScene = reader.ReadBool();

                        Vector3    position = new Vector3(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                        Quaternion rotation = Quaternion.Euler(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());

                        NetworkedObject networkedObject = SpawnManager.CreateLocalNetworkedObject(false, 0, prefabHash, position, rotation);
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, destroyWithScene);
                    }
                }
            }
            else
            {
                NetworkedObject[] networkedObjects = MonoBehaviour.FindObjectsOfType <NetworkedObject>();

                SpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkedObjects);

                using (PooledBitReader reader = PooledBitReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject = reader.ReadBool();
                        ulong networkId      = reader.ReadUInt64Packed();
                        ulong owner          = reader.ReadUInt64Packed();

                        ulong instanceId = reader.ReadUInt64Packed();

                        bool destroyWithScene = reader.ReadBool();

                        NetworkedObject networkedObject = SpawnManager.CreateLocalNetworkedObject(true, instanceId, 0, null, null);
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, destroyWithScene);
                    }
                }
            }

            using (PooledBitStream stream = PooledBitStream.Get())
            {
                using (PooledBitWriter writer = PooledBitWriter.Get(stream))
                {
                    writer.WriteByteArray(switchSceneGuid.ToByteArray());
                    InternalMessageHandler.Send(NetworkingManager.Singleton.ServerClientId, MLAPIConstants.MLAPI_CLIENT_SWITCH_SCENE_COMPLETED, "MLAPI_INTERNAL", stream, SecuritySendFlags.None, null);
                }
            }

            isSwitching = false;

            if (OnSceneSwitched != null)
            {
                OnSceneSwitched();
            }
        }
Ejemplo n.º 16
0
        private static void OnSceneUnloadServer(Guid switchSceneGuid)
        {
            // Justification: Rare alloc, could(should?) reuse
            List <NetworkedObject> newSceneObjects = new List <NetworkedObject>();

            {
                NetworkedObject[] networkedObjects = MonoBehaviour.FindObjectsOfType <NetworkedObject>();

                for (int i = 0; i < networkedObjects.Length; i++)
                {
                    if (networkedObjects[i].IsSceneObject == null)
                    {
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObjects[i], SpawnManager.GetNetworkObjectId(), true, false, null, null, false, 0, false, true);

                        newSceneObjects.Add(networkedObjects[i]);
                    }
                }
            }


            for (int j = 0; j < NetworkingManager.Singleton.ConnectedClientsList.Count; j++)
            {
                if (NetworkingManager.Singleton.ConnectedClientsList[j].ClientId != NetworkingManager.Singleton.ServerClientId)
                {
                    using (PooledBitStream stream = PooledBitStream.Get())
                    {
                        using (PooledBitWriter writer = PooledBitWriter.Get(stream))
                        {
                            writer.WriteUInt32Packed(CurrentActiveSceneIndex);
                            writer.WriteByteArray(switchSceneGuid.ToByteArray());

                            uint sceneObjectsToSpawn = 0;
                            for (int i = 0; i < newSceneObjects.Count; i++)
                            {
                                if (newSceneObjects[i].observers.Contains(NetworkingManager.Singleton.ConnectedClientsList[j].ClientId))
                                {
                                    sceneObjectsToSpawn++;
                                }
                            }

                            writer.WriteUInt32Packed(sceneObjectsToSpawn);

                            for (int i = 0; i < newSceneObjects.Count; i++)
                            {
                                if (newSceneObjects[i].observers.Contains(NetworkingManager.Singleton.ConnectedClientsList[j].ClientId))
                                {
                                    if (NetworkingManager.Singleton.NetworkConfig.UsePrefabSync)
                                    {
                                        writer.WriteBool(newSceneObjects[i].IsPlayerObject);
                                        writer.WriteUInt64Packed(newSceneObjects[i].NetworkId);
                                        writer.WriteUInt64Packed(newSceneObjects[i].OwnerClientId);

                                        writer.WriteUInt64Packed(newSceneObjects[i].PrefabHash);

                                        writer.WriteBool(newSceneObjects[i].DestroyWithScene);

                                        writer.WriteSinglePacked(newSceneObjects[i].transform.position.x);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.position.y);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.position.z);

                                        writer.WriteSinglePacked(newSceneObjects[i].transform.rotation.eulerAngles.x);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.rotation.eulerAngles.y);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.rotation.eulerAngles.z);

                                        if (NetworkingManager.Singleton.NetworkConfig.EnableNetworkedVar)
                                        {
                                            newSceneObjects[i].WriteNetworkedVarData(stream, NetworkingManager.Singleton.ConnectedClientsList[j].ClientId);
                                        }
                                    }
                                    else
                                    {
                                        writer.WriteBool(newSceneObjects[i].IsPlayerObject);
                                        writer.WriteUInt64Packed(newSceneObjects[i].NetworkId);
                                        writer.WriteUInt64Packed(newSceneObjects[i].OwnerClientId);

                                        writer.WriteUInt64Packed(newSceneObjects[i].NetworkedInstanceId);

                                        writer.WriteBool(newSceneObjects[i].DestroyWithScene);

                                        if (NetworkingManager.Singleton.NetworkConfig.EnableNetworkedVar)
                                        {
                                            newSceneObjects[i].WriteNetworkedVarData(stream, NetworkingManager.Singleton.ConnectedClientsList[j].ClientId);
                                        }
                                    }
                                }
                            }
                        }

                        InternalMessageHandler.Send(NetworkingManager.Singleton.ConnectedClientsList[j].ClientId, MLAPIConstants.MLAPI_SWITCH_SCENE, "MLAPI_INTERNAL", stream, SecuritySendFlags.None, null);
                    }
                }
            }

            //Tell server that scene load is completed
            if (NetworkingManager.Singleton.IsHost)
            {
                OnClientSwitchSceneCompleted(NetworkingManager.Singleton.LocalClientId, switchSceneGuid);
            }

            isSwitching = false;

            if (OnSceneSwitched != null)
            {
                OnSceneSwitched();
            }
        }
        private static void OnSceneUnloadClient(Guid switchSceneGuid, Stream objectStream)
        {
            if (!NetworkManager.Singleton.NetworkConfig.EnableSceneManagement || NetworkManager.Singleton.NetworkConfig.UsePrefabSync)
            {
                NetworkSpawnManager.DestroySceneObjects();

                using (var reader = PooledNetworkReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject  = reader.ReadBool();
                        ulong networkId       = reader.ReadUInt64Packed();
                        ulong owner           = reader.ReadUInt64Packed();
                        bool  hasParent       = reader.ReadBool();
                        ulong?parentNetworkId = null;

                        if (hasParent)
                        {
                            parentNetworkId = reader.ReadUInt64Packed();
                        }

                        ulong prefabHash = reader.ReadUInt64Packed();

                        Vector3?   position = null;
                        Quaternion?rotation = null;
                        if (reader.ReadBool())
                        {
                            position = new Vector3(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                            rotation = Quaternion.Euler(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                        }

                        var networkObject = NetworkSpawnManager.CreateLocalNetworkObject(false, 0, prefabHash, parentNetworkId, position, rotation);
                        NetworkSpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, false);

                        var bufferQueue = BufferManager.ConsumeBuffersForNetworkId(networkId);

                        // Apply buffered messages
                        if (bufferQueue != null)
                        {
                            while (bufferQueue.Count > 0)
                            {
                                BufferManager.BufferedMessage message = bufferQueue.Dequeue();
                                NetworkManager.Singleton.HandleIncomingData(message.SenderClientId, message.NetworkChannel, new ArraySegment <byte>(message.NetworkBuffer.GetBuffer(), (int)message.NetworkBuffer.Position, (int)message.NetworkBuffer.Length), message.ReceiveTime, false);
                                BufferManager.RecycleConsumedBufferedMessage(message);
                            }
                        }
                    }
                }
            }
            else
            {
                var networkObjects = MonoBehaviour.FindObjectsOfType <NetworkObject>();
                NetworkSpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkObjects);

                using (var reader = PooledNetworkReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject  = reader.ReadBool();
                        ulong networkId       = reader.ReadUInt64Packed();
                        ulong owner           = reader.ReadUInt64Packed();
                        bool  hasParent       = reader.ReadBool();
                        ulong?parentNetworkId = null;

                        if (hasParent)
                        {
                            parentNetworkId = reader.ReadUInt64Packed();
                        }

                        ulong instanceId = reader.ReadUInt64Packed();

                        var networkObject = NetworkSpawnManager.CreateLocalNetworkObject(true, instanceId, 0, parentNetworkId, null, null);
                        NetworkSpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, false);

                        var bufferQueue = BufferManager.ConsumeBuffersForNetworkId(networkId);

                        // Apply buffered messages
                        if (bufferQueue != null)
                        {
                            while (bufferQueue.Count > 0)
                            {
                                BufferManager.BufferedMessage message = bufferQueue.Dequeue();
                                NetworkManager.Singleton.HandleIncomingData(message.SenderClientId, message.NetworkChannel, new ArraySegment <byte>(message.NetworkBuffer.GetBuffer(), (int)message.NetworkBuffer.Position, (int)message.NetworkBuffer.Length), message.ReceiveTime, false);
                                BufferManager.RecycleConsumedBufferedMessage(message);
                            }
                        }
                    }
                }
            }

            using (var buffer = PooledNetworkBuffer.Get())
                using (var writer = PooledNetworkWriter.Get(buffer))
                {
                    writer.WriteByteArray(switchSceneGuid.ToByteArray());
                    InternalMessageSender.Send(NetworkManager.Singleton.ServerClientId, NetworkConstants.CLIENT_SWITCH_SCENE_COMPLETED, NetworkChannel.Internal, buffer);
                }

            s_IsSwitching = false;

            OnSceneSwitched?.Invoke();
        }
Ejemplo n.º 18
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();

        currentSelectable = GetComponent <TestSelectable>();

        var modules      = Modules;
        var needyModules = NeedyModules;

        fakeInfo.needyModules      = needyModules.ToList();
        currentSelectable.Children = new TestSelectable[modules.Length + needyModules.Length];
        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            currentSelectable.Children[i] = modules[i].GetComponent <TestSelectable>();
            modules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));

            modules[i].OnPass = delegate() {
                Debug.Log("Module Passed");
                fakeInfo.modules.Remove(fakeInfo.modules.First(t => t.Key.Equals(mod)));
                fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = true;
                foreach (KeyValuePair <KMBombModule, bool> m in fakeInfo.modules)
                {
                    if (!m.Value)
                    {
                        allSolved = false;
                        break;
                    }
                }
                if (allSolved)
                {
                    fakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate() {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            currentSelectable.Children[modules.Length + i]         = needyModules[i].GetComponent <TestSelectable>();
            needyModules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            Handlers(needyModules[i].GetComponent <KMBombInfo>());

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
Ejemplo n.º 19
0
    public static void SetIsometry()
    {
        Line[]       lns  = MonoBehaviour.FindObjectsOfType <Line>();
        GameObject[] objs = MonoBehaviour.FindObjectsOfType <GameObject>();
        for (int j = 0; j < lns.Length; j++)
        {
            lns[j].Isometry = -1;
        }
        int count = 0;

        for (int i = objs.Length - 1; i >= 0; i--)// ナゾの仕様だが仕方ない。
        {
            Module md = objs[i].GetComponent <Module>();
            if (md != null && md.Type == MENU.LINES_ISOMETRY)
            {
                //Debug.Log("line isometry exists"+i+":"+md);
                Line LinkLine1 = null, LinkLine2 = null;
                for (int j = 0; j < lns.Length; j++)
                {
                    Line ln = lns[j];
                    if (ln.Id == md.Object1Id)
                    {
                        LinkLine1 = ln;
                    }
                    else if (ln.Id == md.Object2Id)
                    {
                        LinkLine2 = ln;
                    }
                }
                if (LinkLine1.Isometry == -1 && LinkLine2.Isometry == -1)
                {//新しい等長の組
                    LinkLine1.Isometry = count;
                    LinkLine2.Isometry = count;
                    count++;
                }
                else if (LinkLine1.Isometry == -1 && LinkLine2.Isometry != -1)
                {
                    LinkLine1.Isometry = LinkLine2.Isometry;
                }
                else if (LinkLine1.Isometry != -1 && LinkLine2.Isometry == -1)
                {
                    LinkLine2.Isometry = LinkLine1.Isometry;
                }
                else if (LinkLine1.Isometry != -1 && LinkLine2.Isometry != -1)
                {
                    if (LinkLine1.Isometry < LinkLine2.Isometry)
                    {
                        for (int j = 0; j < lns.Length; j++)
                        {
                            if (lns[j].Isometry == LinkLine2.Isometry)
                            {
                                lns[i].Isometry = LinkLine1.Isometry;
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < lns.Length; j++)
                        {
                            if (lns[j].Isometry == LinkLine1.Isometry)
                            {
                                lns[j].Isometry = LinkLine2.Isometry;
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 20
0
 public static bool SaveLogToTeX()
 {
     if (logs == null || AppMgr.cis == null || AppMgr.pts == null)
     {
         return(false);
     }
     try
     {
         using (StreamWriter writer = new StreamWriter(Application.dataPath + "/../../PointLine.tex", false))
         {
             writer.WriteLine("\\documentclass[10pt,dvipdfmx]{article}");
             writer.WriteLine("\\usepackage{pgf,tikz}");
             writer.WriteLine("\\usepackage{mathrsfs}");
             writer.WriteLine("\\pagestyle{empty}");
             writer.WriteLine("\\begin{document}");
             writer.WriteLine("\\begin{tikzpicture}[line cap=round,line join=round,x=0.5cm,y=0.5cm]");
             writer.WriteLine("\\clip(" + AppMgr.LeftBottom.x + "," + AppMgr.LeftBottom.y + ") rectangle (" + AppMgr.RightUp.x + "," + AppMgr.RightUp.y + ");");
             writer.Flush();
             for (int i = 0; i < LogLength; i++)
             {
                 Log l = logs[i];
                 //Debug.Log(""+ l.ObjectType);
                 if (l.ObjectType == "Circle")
                 {
                     AppMgr.cis = MonoBehaviour.FindObjectsOfType <Circle>();
                     // l.Radiusの最新情報を取得する
                     for (int k = 0; k < AppMgr.cis.Length; k++)
                     {
                         if (AppMgr.cis[k].Id == l.Id)
                         {
                             l.Radius = AppMgr.cis[k].Radius;
                             break;
                         }
                     }
                     AppMgr.pts = MonoBehaviour.FindObjectsOfType <Point>();
                     for (int j = 0; j < AppMgr.pts.Length; j++)
                     {
                         if (AppMgr.pts[j].Id == l.Object1Id)
                         {
                             writer.Write("\\draw(" + AppMgr.pts[j].Vec.x + "," + AppMgr.pts[j].Vec.y + ")");
                             writer.WriteLine(" circle (" + l.Radius + ");");
                             writer.Flush();
                             break;
                         }
                     }
                 }
                 else if (l.ObjectType == "Line")
                 {
                     AppMgr.pts = MonoBehaviour.FindObjectsOfType <Point>();
                     int j1 = -1, j2 = -1;
                     for (int j = 0; j < AppMgr.pts.Length; j++)
                     {
                         if (AppMgr.pts[j].Id == l.Object1Id)
                         {
                             j1 = j;
                         }
                         if (AppMgr.pts[j].Id == l.Object2Id)
                         {
                             j2 = j;
                         }
                     }
                     writer.WriteLine("\\draw (" + AppMgr.pts[j1].Vec.x + "," + AppMgr.pts[j1].Vec.y + ")-- (" + AppMgr.pts[j2].Vec.x + "," + AppMgr.pts[j2].Vec.y + ");");
                     writer.Flush();
                 }
                 else if (l.ObjectType == "Point")
                 {
                     AppMgr.pts = MonoBehaviour.FindObjectsOfType <Point>();
                     int id = l.Id;
                     //FindPointFromId();
                     Point pt = null;
                     for (int k = 0; k < AppMgr.pts.Length; k++)
                     {
                         if (AppMgr.pts[k].Id == id)
                         {
                             pt = AppMgr.pts[k];
                         }
                     }
                     writer.WriteLine("\\draw[fill=black](" + pt.Vec.x + "," + pt.Vec.y + ") circle  (1.5pt);");
                     writer.Flush();
                     // 文字を添えるかどうか
                 }
             }
             writer.WriteLine("\\end{tikzpicture}");
             writer.WriteLine("\\end{document}");
             writer.Flush();
             writer.Close();
         }
     }
     catch (Exception e)
     {
         Debug.Log(e.Message);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 21
0
    public void OnRenderObject()
    {
        //Set up layer-light dictionary

        if (Camera.current == Camera.main)
        {
            var           camera = Camera.main;
            CommandBuffer cb     = new CommandBuffer();

            var lightTexId   = GetTemporaryRTId("_LightMap", cb, GenCameraTex(camera, RenderTextureFormat.ARGBFloat, 0.3f));
            var shadowTexId  = GetTemporaryRTId("_ShadowMap", cb, GenCameraTex(camera, RenderTextureFormat.RFloat, 0.3f));
            var diffuseTexId = GetTemporaryRTId("_DiffuseMap", cb, GenCameraTex(camera, RenderTextureFormat.ARGBFloat));

            var renderers = MonoBehaviour.FindObjectsOfType <LightRenderer>();
            var lightsMap = new Dictionary <string, List <LightRenderer> >();
            foreach (var layer in lightLayerMap.Keys)
            {
                lightsMap.Add(layer, new List <LightRenderer>());
            }
            foreach (var renderer in renderers)
            {
                string layer = renderer.layer;
                if (lightsMap.ContainsKey(layer))
                {
                    lightsMap[layer].Add(renderer);
                }
            }
            if (lightMeshM == null)
            {
                lightMeshM = new Material(LightViewMesh);
            }
            foreach (var layer in lightLayerMap.Keys)
            {
                var runtimeData = runtimeDatasMap[layer];
                var lightLayer  = lightLayerMap[layer];

                cb.SetRenderTarget(lightTexId);
                cb.ClearRenderTarget(false, true, Color.black);
                foreach (var renderer in lightsMap[layer])
                {
                    cb.SetRenderTarget(shadowTexId);
                    cb.ClearRenderTarget(false, true, Color.black);
                    renderer.PointLight.DrawShadowMesh(ref cb);
                    cb.SetRenderTarget(lightTexId);
                    renderer.PointLight.DrawLightMesh(ref cb, shadowTexId);
                }
                // Blur light tex.
                //BlurEffect.SetBlurSize(lightLayer.blurSize);
                //BlurEffect.SetIterTimes(lightLayer.iterTimes);
                //BlurEffect.BlurBlit(ref runtimeData.lightTexture);
                //DrawMesh(lightTexLayer, runtimeData.blurCamera, runtimeData.lightTexture);
                // Mix catch texture with light texture
                cb.Blit(runtimeData.catchTexture, diffuseTexId);
                cb.SetRenderTarget(diffuseTexId);
                DrawScreenTex(cb, lightTexId, camera, LightMixMesh);
                cb.SetRenderTarget(finalTexture);
                DrawScreenTex(cb, diffuseTexId, camera, ScreenMix);
            }
            Graphics.ExecuteCommandBuffer(cb);
        }
    }
Ejemplo n.º 22
0
        internal static void OnPostLoad(RandoGame randoGame)
        {
            foreach (var obj in GameObject.FindObjectsOfType <AdventureSpecialIntro>())
            {
                GameObject.Destroy(obj.gameObject);
            }

            if (!(Game.LevelName == "Enemy" || Game.LevelName == "Credits"))
            {
                // remove warpanchor cutscenes but keep all warpanchors present in arcade mode
                // (this could allow for abyss to unlock an ability)
                foreach (var obj in MonoBehaviour.FindObjectsOfType <WarpAnchor>())
                {
                    if (obj.ignoreInArcade_)
                    {
                        obj.ignoreInAdventure_ = true;
                    }
                    else if (obj.ignoreInAdventure_)
                    {
                        obj.ignoreInAdventure_ = false;
                    }
                }

                foreach (var obj in GameObject.FindObjectsOfType <GlitchFieldLogic>())
                {
                    if (obj.ignoreInArcade_)
                    {
                        GameObject.Destroy(obj.gameObject);
                    }
                }
            }
            else if (Game.LevelName == "Enemy")
            {
                // Enemy specific changes

                // Shorten the warp to earth cutscene by grabbing the relevant warp anchor
                // (in this case, the one just before the waterfall area) and altering its properties a bit
                foreach (var obj in GameObject.FindObjectsOfType <WarpAnchor>())
                {
                    if (obj.myID_ == 0 && obj.otherID_ == 51)
                    {
                        obj.otherID_          = 53;
                        obj.slowmoSpeed_      = 1.0f;
                        obj.time_             = 0.2f;
                        obj.transitionEffect_ = WarpAnchor.TransitionEffect.Teleport;
                        obj.audioEventAfter_  = "Stop_DU_ending_sequence";
                    }
                }

                // Remove the SetAbilitiesTrigger that disables all your abilties at the end
                foreach (var obj in GameObject.FindObjectsOfType <SetAbilitiesTrigger>())
                {
                    if (obj.enableBoosting_ == false &&
                        obj.enableJumping_ == false &&
                        obj.enableFlying_ == false &&
                        obj.enableJetRotating_ == false)
                    {
                        obj.Destroy();
                    }
                }
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Finds any loaded components that implement the specified interfaces
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static T[] FindInterfaces <T>() where T : class
 {
     return(MonoBehaviour.FindObjectsOfType <MonoBehaviour>().OfType <T>().ToArray());
     //return MonoBehaviour.FindObjectsOfType<MonoBehaviour>().Select(c => c as T).Where(c => c != null).ToArray();
 }
Ejemplo n.º 24
0
        private static void OnSceneUnloadClient(Guid switchSceneGuid, Stream objectStream)
        {
            if (!NetworkingManager.Singleton.NetworkConfig.EnableSceneManagement || NetworkingManager.Singleton.NetworkConfig.UsePrefabSync)
            {
                SpawnManager.DestroySceneObjects();

                using (PooledBitReader reader = PooledBitReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject  = reader.ReadBool();
                        ulong networkId       = reader.ReadUInt64Packed();
                        ulong owner           = reader.ReadUInt64Packed();
                        bool  hasParent       = reader.ReadBool();
                        ulong?parentNetworkId = null;

                        if (hasParent)
                        {
                            parentNetworkId = reader.ReadUInt64Packed();
                        }

                        ulong prefabHash = reader.ReadUInt64Packed();

                        Vector3?   position = null;
                        Quaternion?rotation = null;
                        if (reader.ReadBool())
                        {
                            position = new Vector3(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                            rotation = Quaternion.Euler(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                        }

                        NetworkedObject networkedObject = SpawnManager.CreateLocalNetworkedObject(false, 0, prefabHash, parentNetworkId, position, rotation);
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, false);

                        Queue <BufferManager.BufferedMessage> bufferQueue = BufferManager.ConsumeBuffersForNetworkId(networkId);

                        // Apply buffered messages
                        if (bufferQueue != null)
                        {
                            while (bufferQueue.Count > 0)
                            {
                                BufferManager.BufferedMessage message = bufferQueue.Dequeue();

                                NetworkingManager.Singleton.HandleIncomingData(message.sender, message.channelName, new ArraySegment <byte>(message.payload.GetBuffer(), (int)message.payload.Position, (int)message.payload.Length), message.receiveTime, false);

                                BufferManager.RecycleConsumedBufferedMessage(message);
                            }
                        }
                    }
                }
            }
            else
            {
                NetworkedObject[] networkedObjects = MonoBehaviour.FindObjectsOfType <NetworkedObject>();

                SpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkedObjects);

                using (PooledBitReader reader = PooledBitReader.Get(objectStream))
                {
                    uint newObjectsCount = reader.ReadUInt32Packed();

                    for (int i = 0; i < newObjectsCount; i++)
                    {
                        bool  isPlayerObject  = reader.ReadBool();
                        ulong networkId       = reader.ReadUInt64Packed();
                        ulong owner           = reader.ReadUInt64Packed();
                        bool  hasParent       = reader.ReadBool();
                        ulong?parentNetworkId = null;

                        if (hasParent)
                        {
                            parentNetworkId = reader.ReadUInt64Packed();
                        }

                        ulong instanceId = reader.ReadUInt64Packed();

                        NetworkedObject networkedObject = SpawnManager.CreateLocalNetworkedObject(true, instanceId, 0, parentNetworkId, null, null);
                        SpawnManager.SpawnNetworkedObjectLocally(networkedObject, networkId, true, isPlayerObject, owner, objectStream, false, 0, true, false);

                        Queue <BufferManager.BufferedMessage> bufferQueue = BufferManager.ConsumeBuffersForNetworkId(networkId);

                        // Apply buffered messages
                        if (bufferQueue != null)
                        {
                            while (bufferQueue.Count > 0)
                            {
                                BufferManager.BufferedMessage message = bufferQueue.Dequeue();

                                NetworkingManager.Singleton.HandleIncomingData(message.sender, message.channelName, new ArraySegment <byte>(message.payload.GetBuffer(), (int)message.payload.Position, (int)message.payload.Length), message.receiveTime, false);

                                BufferManager.RecycleConsumedBufferedMessage(message);
                            }
                        }
                    }
                }
            }

            using (PooledBitStream stream = PooledBitStream.Get())
            {
                using (PooledBitWriter writer = PooledBitWriter.Get(stream))
                {
                    writer.WriteByteArray(switchSceneGuid.ToByteArray());
                    NetworkedObject networkedObject = null;
                    InternalMessageSender.Send(NetworkingManager.Singleton.ServerClientId, MLAPIConstants.MLAPI_CLIENT_SWITCH_SCENE_COMPLETED, "MLAPI_INTERNAL", stream, SecuritySendFlags.None, networkedObject);
                }
            }

            isSwitching = false;

            if (OnSceneSwitched != null)
            {
                OnSceneSwitched();
            }
        }
Ejemplo n.º 25
0
 public static void SetupReceivers()
 {
     callbackReceiver = new List <NodeEditorCallbackReceiver> (MonoBehaviour.FindObjectsOfType <NodeEditorCallbackReceiver> ());
     receiverCount    = callbackReceiver.Count;
 }
Ejemplo n.º 26
0
 private static void LoadFileUsingPath(string path)
 {
     ClickOnPanel.DeleteAll();
     if (path != null && path.Length != 0)
     {
         try
         {
             using (StreamReader reader = new StreamReader(path, false))
             {
                 InitLog();
                 string str;
                 int    PId = -1, LId = -1, CId = -1, MId = -1;
                 do
                 {
                     str = reader.ReadLine();
                     if (str == null)
                     {
                         break;             //多分要らない。
                     }
                     else
                     {
                         Log lg = GetLogFromString(str);
                         //AddLog(lg);
                         if (lg.ObjectType == "Point")
                         {
                             if (PId < lg.Id)
                             {
                                 PId = lg.Id;
                             }
                         }
                         else if (lg.ObjectType == "Line")
                         {
                             if (LId < lg.Id)
                             {
                                 LId = lg.Id;
                             }
                         }
                         else if (lg.ObjectType == "Circle")
                         {
                             if (CId < lg.Id)
                             {
                                 CId = lg.Id;
                             }
                         }
                         else if (lg.ObjectType == "Module")
                         {
                             if (MId < lg.Id)
                             {
                                 MId = lg.Id;
                             }
                         }
                     }
                 }while (str != null);
                 reader.Close();
                 ClickOnPanel.SetId(PId + 1, LId + 1, CId + 1, MId + 1);
                 AppMgr.pts = MonoBehaviour.FindObjectsOfType <Point>();
                 AppMgr.lns = MonoBehaviour.FindObjectsOfType <Line>();
                 AppMgr.cis = MonoBehaviour.FindObjectsOfType <Circle>();
                 AppMgr.mds = MonoBehaviour.FindObjectsOfType <Module>();
             }
         }
         catch (Exception e)
         {
             Debug.Log(e.Message);
         }
     }
     else
     {
         Debug.Log("Invalid path given");
     }
     AppMgr.DrawOn       = true;
     AppMgr.KeyOn        = true;
     AppMgr.FileDialogOn = false;
 }
Ejemplo n.º 27
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();
        foreach (MonoBehaviour s in scripts)
        {
            IEnumerable <FieldInfo> fields = s.GetType().GetFields();
            foreach (FieldInfo f in fields)
            {
                if (f.FieldType.Equals(typeof(KMBombInfo)))
                {
                    KMBombInfo component = (KMBombInfo)f.GetValue(s);
                    fakeInfo.Detonate += delegate { if (component.OnBombExploded != null)
                                                    {
                                                        component.OnBombExploded();
                                                    }
                    };
                    fakeInfo.HandleSolved += delegate { if (component.OnBombSolved != null)
                                                        {
                                                            component.OnBombSolved();
                                                        }
                    };
                }
            }
        }

        currentSelectable = GetComponent <TestSelectable>();

        KMBombModule[]  modules      = FindObjectsOfType <KMBombModule>();
        KMNeedyModule[] needyModules = FindObjectsOfType <KMNeedyModule>();
        fakeInfo.needyModules            = needyModules.ToList();
        currentSelectable.Children       = new TestSelectable[modules.Length + needyModules.Length];
        currentSelectable.ChildRowLength = currentSelectable.Children.Length;
        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            TestSelectable testSelectable = modules[i].GetComponent <TestSelectable>();
            currentSelectable.Children[i] = testSelectable;
            testSelectable.Parent         = currentSelectable;
            testSelectable.x = i;

            fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));
            modules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                fakeInfo.modules.Remove(fakeInfo.modules.First(t => t.Key.Equals(mod)));
                fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = true;
                foreach (KeyValuePair <KMBombModule, bool> m in fakeInfo.modules)
                {
                    if (!m.Value)
                    {
                        allSolved = false;
                        break;
                    }
                }
                if (allSolved)
                {
                    fakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            TestSelectable testSelectable = needyModules[i].GetComponent <TestSelectable>();
            currentSelectable.Children[modules.Length + i] = testSelectable;
            testSelectable.Parent = currentSelectable;
            testSelectable.x      = modules.Length + i;

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
Ejemplo n.º 28
0
 public static bool OpenLog(string path)
 {
     //ストリームリーダーreaderから読み込む
     try
     {
         using (StreamReader reader = new StreamReader(Application.dataPath + "/Resources/" + path, false))
         {
             InitLog();
             string str;
             int    PId = -1, LId = -1, CId = -1, MId = -1;
             do
             {
                 str = reader.ReadLine();
                 if (str == null)
                 {
                     break;             //多分要らない。
                 }
                 else
                 {
                     Log lg = GetLogFromString(str);
                     //AddLog(lg);
                     if (lg.ObjectType == "Point")
                     {
                         if (PId < lg.Id)
                         {
                             PId = lg.Id;
                         }
                     }
                     else if (lg.ObjectType == "Line")
                     {
                         if (LId < lg.Id)
                         {
                             LId = lg.Id;
                         }
                     }
                     else if (lg.ObjectType == "Circle")
                     {
                         if (CId < lg.Id)
                         {
                             CId = lg.Id;
                         }
                     }
                     else if (lg.ObjectType == "Module")
                     {
                         if (MId < lg.Id)
                         {
                             MId = lg.Id;
                         }
                     }
                 }
             }while (str != null);
             reader.Close();
             ClickOnPanel.SetId(PId + 1, LId + 1, CId + 1, MId + 1);
             AppMgr.pts = MonoBehaviour.FindObjectsOfType <Point>();
             AppMgr.lns = MonoBehaviour.FindObjectsOfType <Line>();
             AppMgr.cis = MonoBehaviour.FindObjectsOfType <Circle>();
             AppMgr.mds = MonoBehaviour.FindObjectsOfType <Module>();
         }
     }
     catch (Exception e)
     {
         Debug.Log(e.Message);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 29
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();
        foreach (MonoBehaviour s in scripts)
        {
            IEnumerable <FieldInfo> fields = s.GetType().GetFields();
            foreach (FieldInfo f in fields)
            {
                if (f.FieldType.Equals(typeof(KMBombInfo)))
                {
                    KMBombInfo component = (KMBombInfo)f.GetValue(s);
                    if (component.OnBombExploded != null)
                    {
                        fakeInfo.Detonate += new FakeBombInfo.OnDetonate(component.OnBombExploded);
                    }
                    if (component.OnBombSolved != null)
                    {
                        fakeInfo.HandleSolved += new FakeBombInfo.OnSolved(component.OnBombSolved);
                    }
                    continue;
                }
            }
        }

        currentSelectable = GetComponent <TestSelectable>();

        KMBombModule[]  modules      = FindObjectsOfType <KMBombModule>();
        KMNeedyModule[] needyModules = FindObjectsOfType <KMNeedyModule>();
        fakeInfo.needyModules      = needyModules.ToList();
        currentSelectable.Children = new TestSelectable[modules.Length + needyModules.Length];
        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            currentSelectable.Children[i] = modules[i].GetComponent <TestSelectable>();
            modules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));
            modules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                fakeInfo.modules.Remove(fakeInfo.modules.First(t => t.Key.Equals(mod)));
                fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = true;
                foreach (KeyValuePair <KMBombModule, bool> m in fakeInfo.modules)
                {
                    if (!m.Value)
                    {
                        allSolved = false;
                        break;
                    }
                }
                if (allSolved)
                {
                    fakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            currentSelectable.Children[modules.Length + i]         = needyModules[i].GetComponent <TestSelectable>();
            needyModules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();


        //Load all the audio clips in the asset database
        audioClips = new List <AudioClip>();
        string[] audioClipAssetGUIDs = AssetDatabase.FindAssets("t:AudioClip");

        foreach (var guid in audioClipAssetGUIDs)
        {
            AudioClip clip = AssetDatabase.LoadAssetAtPath <AudioClip>(AssetDatabase.GUIDToAssetPath(guid));

            if (clip != null)
            {
                audioClips.Add(clip);
            }
        }

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
        private static void OnSceneUnloadServer(Guid switchSceneGuid)
        {
            // Justification: Rare alloc, could(should?) reuse
            var newSceneObjects = new List <NetworkObject>();

            {
                var networkObjects = MonoBehaviour.FindObjectsOfType <NetworkObject>();
                for (int i = 0; i < networkObjects.Length; i++)
                {
                    if (networkObjects[i].IsSceneObject == null)
                    {
                        NetworkSpawnManager.SpawnNetworkObjectLocally(networkObjects[i], NetworkSpawnManager.GetNetworkObjectId(), true, false, null, null, false, 0, false, true);
                        newSceneObjects.Add(networkObjects[i]);
                    }
                }
            }

            for (int j = 0; j < NetworkManager.Singleton.ConnectedClientsList.Count; j++)
            {
                if (NetworkManager.Singleton.ConnectedClientsList[j].ClientId != NetworkManager.Singleton.ServerClientId)
                {
                    using (var buffer = PooledNetworkBuffer.Get())
                        using (var writer = PooledNetworkWriter.Get(buffer))
                        {
                            writer.WriteUInt32Packed(CurrentActiveSceneIndex);
                            writer.WriteByteArray(switchSceneGuid.ToByteArray());

                            uint sceneObjectsToSpawn = 0;
                            for (int i = 0; i < newSceneObjects.Count; i++)
                            {
                                if (newSceneObjects[i].m_Observers.Contains(NetworkManager.Singleton.ConnectedClientsList[j].ClientId))
                                {
                                    sceneObjectsToSpawn++;
                                }
                            }

                            writer.WriteUInt32Packed(sceneObjectsToSpawn);

                            for (int i = 0; i < newSceneObjects.Count; i++)
                            {
                                if (newSceneObjects[i].m_Observers.Contains(NetworkManager.Singleton.ConnectedClientsList[j].ClientId))
                                {
                                    writer.WriteBool(newSceneObjects[i].IsPlayerObject);
                                    writer.WriteUInt64Packed(newSceneObjects[i].NetworkObjectId);
                                    writer.WriteUInt64Packed(newSceneObjects[i].OwnerClientId);

                                    NetworkObject parentNetworkObject = null;

                                    if (!newSceneObjects[i].AlwaysReplicateAsRoot && newSceneObjects[i].transform.parent != null)
                                    {
                                        parentNetworkObject = newSceneObjects[i].transform.parent.GetComponent <NetworkObject>();
                                    }

                                    if (parentNetworkObject == null)
                                    {
                                        writer.WriteBool(false);
                                    }
                                    else
                                    {
                                        writer.WriteBool(true);
                                        writer.WriteUInt64Packed(parentNetworkObject.NetworkObjectId);
                                    }

                                    if (!NetworkManager.Singleton.NetworkConfig.EnableSceneManagement || NetworkManager.Singleton.NetworkConfig.UsePrefabSync)
                                    {
                                        writer.WriteUInt64Packed(newSceneObjects[i].PrefabHash);

                                        writer.WriteSinglePacked(newSceneObjects[i].transform.position.x);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.position.y);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.position.z);

                                        writer.WriteSinglePacked(newSceneObjects[i].transform.rotation.eulerAngles.x);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.rotation.eulerAngles.y);
                                        writer.WriteSinglePacked(newSceneObjects[i].transform.rotation.eulerAngles.z);
                                    }
                                    else
                                    {
                                        writer.WriteUInt64Packed(newSceneObjects[i].NetworkInstanceId);
                                    }

                                    if (NetworkManager.Singleton.NetworkConfig.EnableNetworkVariable)
                                    {
                                        newSceneObjects[i].WriteNetworkVariableData(buffer, NetworkManager.Singleton.ConnectedClientsList[j].ClientId);
                                    }
                                }
                            }

                            InternalMessageSender.Send(NetworkManager.Singleton.ConnectedClientsList[j].ClientId, NetworkConstants.SWITCH_SCENE, NetworkChannel.Internal, buffer);
                        }
                }
            }

            //Tell server that scene load is completed
            if (NetworkManager.Singleton.IsHost)
            {
                OnClientSwitchSceneCompleted(NetworkManager.Singleton.LocalClientId, switchSceneGuid);
            }

            s_IsSwitching = false;

            OnSceneSwitched?.Invoke();
        }