コード例 #1
0
    void NetEventMasterServerEvent(NetEvent net_event)
    {
        switch (net_event.master_server_event())
        {
        case MasterServerEvent.HostListReceived:
            ConsoleScript.Log("Received a host list from the master server.");
            if (queued_join_game_name_.Length > 0)
            {
                JoinHostListGameByName(queued_join_game_name_);
                queued_join_game_name_ = "";
            }
            break;

        case MasterServerEvent.RegistrationFailedGameName:
            ConsoleScript.Log("Registration failed because an empty game name was given.");
            break;

        case MasterServerEvent.RegistrationFailedGameType:
            ConsoleScript.Log("Registration failed because an empty game type was given.");
            break;

        case MasterServerEvent.RegistrationFailedNoServer:
            ConsoleScript.Log("Registration failed because no server is running.");
            break;

        case MasterServerEvent.RegistrationSucceeded:
            ConsoleScript.Log("Registration to master server succeeded, received confirmation.");
            break;
        }
    }
コード例 #2
0
    void TargetSongWasSet(int player, int song)
    {
        string song_name = "";

        switch (song)
        {
        case -1:
            song_name = "silence"; break;

        case 0:
            song_name = "\"Forest\""; break;

        case 1:
            song_name = "\"Dungeon\""; break;

        case 2:
            song_name = "\"HellGate\""; break;

        case 3:
            song_name = "\"The Grim\""; break;
        }
        var    player_info_list = PlayerListScript.Instance().GetPlayerInfoList();
        string player_name      = "You";

        if (player_info_list.ContainsKey(player))
        {
            player_name = player_info_list[player].name_;
        }
        ConsoleScript.Log(player_name + " changed song to " + song_name);
        target_song_ = song;
    }
コード例 #3
0
    Dictionary <string, string> ParseURLQuery(string val)
    {
        Dictionary <string, string> element_dictionary = new Dictionary <string, string>();

        string[] question_mark = val.Split('?');
        if (question_mark.Length > 1)
        {
            string query = question_mark[1];
            for (int i = 2; i < question_mark.Length; ++i)
            {
                query += '?' + question_mark[i];
            }
            string[] elements = query.Split('&');
            ConsoleScript.Log("Query parts:");
            foreach (string element in elements)
            {
                string[] parts = element.Split('=');
                if (parts.Length > 1)
                {
                    ConsoleScript.Log(parts[0] + ": " + parts[1]);
                    element_dictionary[parts[0]] = parts[1];
                }
            }
        }
        return(element_dictionary);
    }
コード例 #4
0
ファイル: ObjectManagerScript.cs プロジェクト: zbaker94/FTJ
 void FixedUpdate()
 {
     if (Network.isServer)
     {
         // Move grabbed objects to position of cursor
         foreach (GameObject grabbable in grabbable_objects)
         {
             int held_by_player = grabbable.GetComponent <GrabbableScript>().held_by_player_;
             if (held_by_player != -1)
             {
                 GameObject holder = null;
                 foreach (GameObject cursor in cursor_objects)
                 {
                     if (cursor.GetComponent <CursorScript>().id() == held_by_player)
                     {
                         holder = cursor;
                     }
                 }
                 if (holder)
                 {
                     UpdatePhysicsState(grabbable, holder);
                 }
                 else
                 {
                     ConsoleScript.Log("Could not find cursor for player: " + held_by_player);
                 }
             }
         }
     }
 }
コード例 #5
0
 void JoinGameByName(string val)
 {
     ConsoleScript.Log("Attempting to join game: " + val);
     MasterServer.RequestHostList(GAME_IDENTIFIER);
     SetState(State.JOINING);
     queued_join_game_name_ = val;
     game_name_             = val;
 }
コード例 #6
0
    void NetEventPlayerDisconnected(NetEvent net_event)
    {
        NetworkPlayer player = net_event.network_player();

        ConsoleScript.Log("Player " + player + " disconnected");
        PlayerListScript.Instance().Remove(int.Parse(player.ToString()));
        Network.RemoveRPCs(player);
        Network.DestroyPlayerObjects(player);
    }
コード例 #7
0
 void NetEventFailedToConnectToMasterServer(NetEvent net_event)
 {
     if (state_ == State.JOIN)
     {
         display_err_ = "" + net_event.error();
         SetState(State.MASTER_SERVER_FAIL);
     }
     ConsoleScript.Log("Failed to connect to master server: " + net_event.error());
 }
コード例 #8
0
 void NetEventConnectedToServer()
 {
     if (state_ == State.JOINING)
     {
         SetState(State.JOIN_SUCCESS);
     }
     ConsoleScript.Log("Connected to server with ID: " + Network.player);
     TellServerPlayerName(player_name_);
     Network.Instantiate(cursor_prefab, new Vector3(0, 0, 0), Quaternion.identity, 0);
 }
コード例 #9
0
 void Start()
 {
     RequestPageURLForAutoJoin();
     //TryToCreateGame(true);
     music_        = gameObject.AddComponent <AudioSource>();
     music_.volume = 0.0f;
     music_.loop   = true;
     target_song_  = Random.Range(0, 4);
     ConsoleScript.Log(GAME_IDENTIFIER);
 }
コード例 #10
0
    void ReceivePageURLForAutoJoin(string val)
    {
        ConsoleScript.Log("Received page url");
        Dictionary <string, string> elements = ParseURLQuery(val);

        if (elements.ContainsKey("join"))
        {
            JoinGameByName(elements["join"]);
        }
    }
コード例 #11
0
 void OpenConsole()
 {
     canvas.gameObject.SetActive(true);
     if (need_to_update)
     {
         ConsoleScript.UpdateTask();
         need_to_update = false;
     }
     heromove.is_moving = false;
 }
コード例 #12
0
    void TellServerPlayerName(string name)
    {
        int player_id = int.Parse(Network.player.ToString());

        ConsoleScript.Log("Telling server that player " + player_id + " is named: " + player_name_);
        if (Network.isClient)
        {
            networkView.RPC("SetPlayerName", RPCMode.Server, player_id, name);
        }
        else
        {
            PlayerListScript.Instance().SetPlayerName(player_id, name);
        }
    }
コード例 #13
0
 void NetEventFailedToConnect(NetEvent net_event)
 {
     if (state_ == State.JOINING)
     {
         if (net_event.error() == NetworkConnectionError.InvalidPassword)
         {
             SetState(State.JOIN_PASSWORD);
         }
         else
         {
             display_err_ = "" + net_event.error();
             SetState(State.JOIN_FAIL);
         }
     }
     ConsoleScript.Log("Failed to connect: " + net_event.error());
 }
コード例 #14
0
    void NetEventDisconnectedFromServer(NetEvent net_event)
    {
        switch (net_event.network_disconnection())
        {
        case NetworkDisconnection.Disconnected:
            ConsoleScript.Log("Cleanly disconnected from server");
            break;

        case NetworkDisconnection.LostConnection:
            ConsoleScript.Log("Connection to server was lost unexpectedly");
            break;
        }
        if (state_ == State.NONE || state_ == State.JOIN_SUCCESS || state_ == State.JOINING)
        {
            Application.LoadLevel(Application.loadedLevel);
        }
    }
コード例 #15
0
ファイル: IOHelper.cs プロジェクト: shldn/assembly
 public static void LoadDirectory(string dir)
 {
     if (dir == "")
     {
         return;
     }
     try {
         ConsoleScript.NewLine("Loading directory " + dir);
         string[] filePaths = Directory.GetFiles(dir);
         foreach (string file in filePaths)
         {
             new Assembly(file);
         }
     }
     catch (Exception e) {
         Debug.LogError("LoadDirectory failed: " + e.ToString());
     }
 } // End of LoadDirectory
コード例 #16
0
    void NetEventServerInitialized()
    {
        if (state_ == State.CREATING)
        {
            SetState(State.NONE);
        }
        ConsoleScript.Log("Server initialized");
        int player_id = int.Parse(Network.player.ToString());

        TellServerPlayerName(player_name_);
        Network.Instantiate(board_prefab, GameObject.Find("board_spawn").transform.position, GameObject.Find("board_spawn").transform.rotation, 0);
        int count = 0;

        foreach (Transform player_spawn in GameObject.Find("play_areas").transform)
        {
            GameObject play_area_obj = (GameObject)Network.Instantiate(play_area_prefab, player_spawn.transform.position, player_spawn.transform.rotation, 0);
            play_area_obj.GetComponent <PlayAreaScript>().SetColor(count);
            play_areas.Add(play_area_obj);
            ++count;
        }
        SpawnHealthTokens();

        Network.Instantiate(cursor_prefab, new Vector3(0, 0, 0), Quaternion.identity, 0);
    }
コード例 #17
0
    void Update()
    {
        if (Tabs[0].activeInHierarchy && scriptInputField.isFocused)
        {
            CursorPosition = scriptInputField.caretPosition;
        }

        if (Input.anyKey)
        {
            anyKeyHold = true;
        }

        //TODO: Autocomplete stuff here
        if (Tabs[0].activeInHierarchy)
        {
            //Function Autocomplete: Get the last ( detected. Find the last . before it. Get the Name and the Function kit attached to it and if everything is there display the helper and format some text
            string FunctionHelperText = string.Empty;
            if (scriptInputField.text.Contains("(") && scriptInputField.text.Length > 3)
            {
                string s      = scriptInputField.text;
                int    Phase  = 0;
                string First  = string.Empty;
                string Second = string.Empty;
                int    Lenght = 1;
                for (int i = CursorPosition - 1; i >= 0; i--)
                {
                    if (i >= s.Length)
                    {
                        break;
                    }
                    if (Phase == 0)
                    {
                        if (s[i] == '(')
                        {
                            Phase = 1;
                        }
                        else if (!AllowedChars.Contains(s[i].ToString()))
                        {
                            break;
                        }
                    }
                    else if (Phase == 1)
                    {
                        if (AllowedChars.Contains(s[i].ToString()))
                        {
                            First = First.Insert(0, s[i].ToString());
                        }
                        else if (s[i] == '.')
                        {
                            Phase  = 2;
                            Lenght = 2;
                        }
                        else
                        {
                            Lenght = 1;
                            break;
                        }
                    }
                    else if (Phase == 2)
                    {
                        if (AllowedChars.Contains(s[i].ToString()))
                        {
                            Second = Second.Insert(0, s[i].ToString());
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (Phase > 0)
                {
                    if (Lenght == 1)
                    {
                        if (First.Length > 0)
                        {
                            if (Target.GetComponent <ConsoleScript>().GlobalFunctionNames.Contains(First))
                            {
                                List <Variable> ft = Target.GetComponent <ConsoleScript>().GetFunctionParametersTemplate(First);
                                FunctionHelperText += "(";
                                foreach (Variable v in ft)
                                {
                                    if (FunctionHelperText != "(")
                                    {
                                        FunctionHelperText += ", ";
                                    }

                                    FunctionHelperText += Variable.TypeToString(v.variableType);
                                    FunctionHelperText += " ";
                                    FunctionHelperText += v.Id;
                                }
                                FunctionHelperText += ")";
                            }
                        }
                    }
                    else if (Lenght == 2)
                    {
                        if (First.Length > 0 && Second.Length > 0)
                        {
                            bool k = false;
                            foreach (WInteractable inter in Target.GetComponent <ConsoleScript>().transmitter.sources)
                            {
                                if (inter.Name == Second)
                                {
                                    k = true;
                                }
                            }
                            if (k)
                            {
                                FunctionTemplate ft = Target.GetComponent <ConsoleScript>().transmitter.AccessSpecificInteractableFunction(Second, First);
                                FunctionHelperText += "(";
                                foreach (VariableTemplate v in ft.Parameters)
                                {
                                    if (FunctionHelperText != "(")
                                    {
                                        FunctionHelperText += ", ";
                                    }

                                    FunctionHelperText += Variable.TypeToString(v.variableType);
                                    FunctionHelperText += " ";
                                    FunctionHelperText += v.Id;
                                }
                                FunctionHelperText += ")";
                            }
                        }
                    }
                }
            }
            if (FunctionHelperText.Length > 0)
            {
                FunctionParametersText.text = FunctionHelperText;
                if (!FunctionParameters.gameObject.activeSelf)
                {
                    FunctionParameters.gameObject.SetActive(true);
                }
                Canvas.ForceUpdateCanvases();
                LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)FunctionParameters.transform);
            }
            else
            {
                if (FunctionParameters.gameObject.activeSelf)
                {
                    FunctionParameters.gameObject.SetActive(false);
                }
            }

            ConsoleScript c        = Target.GetComponent <ConsoleScript>();
            string        textpart = string.Empty;
            if (CursorPosition - 1 >= 0 && CursorPosition - 1 < scriptInputField.text.Length)
            {
                if (AllowedChars.Contains(scriptInputField.text[CursorPosition - 1].ToString()))
                {
                    textpart = GetTextAfterCaret(scriptInputField.text, CursorPosition);
                }
                else
                {
                    textpart = string.Empty;
                }
            }
            else
            {
                textpart = string.Empty;
            }

            if (string.IsNullOrEmpty(textpart))
            {
                textpart = " ";
            }

            if (InputControl.GetInput(InputControl.InputType.MouseSecondairyPress))
            {
                Autocomplete.position = Input.mousePosition;
            }

            //Autocomplete
            if ((c.AllowedChars.Contains(textpart[0].ToString()) || (string.IsNullOrWhiteSpace(textpart) || string.IsNullOrEmpty(textpart))) && !char.IsDigit(textpart[0]))
            {
                List <string> AutocompleteResult = GetAutocompleteOptions();

                //Set the position of the autocomplete box and config it
                //Must be able to understand Arrow and Enters
                if (AutocompleteResult.Count > 0 && ((string.IsNullOrWhiteSpace(textpart) || string.IsNullOrEmpty(textpart)) == InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)) || FunctionParameters.gameObject.activeSelf)
                {
                    if (!Autocomplete.gameObject.activeInHierarchy)
                    {
                        Autocomplete.gameObject.SetActive(true);
                    }
                    if ((!Input.anyKey && anyKeyHold) || InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete) && !FunctionParameters.gameObject.activeSelf)
                    {
                        for (int i = 0; i < AutocompleteOptionView.childCount - 1; i++)
                        {
                            Destroy(AutocompleteOptionView.GetChild(i + 1).gameObject);
                        }
                        for (int i = 0; i < AutocompleteResult.Count; i++)
                        {
                            GameObject Option = (GameObject)Instantiate(AutocompleteOptionTemplate.gameObject, AutocompleteOptionView);
                            Option.SetActive(true);
                            int x = i;
                            Option.GetComponent <Button>().onClick.AddListener(() => {
                                LoadAutocompleteOption(x);
                            });
                            Option.transform.GetChild(0).GetComponent <Text>().text = AutocompleteResult[i];
                        }
                    }
                }
                else
                {
                    if (Autocomplete.gameObject.activeInHierarchy && !FunctionParameters.gameObject.activeSelf)
                    {
                        Autocomplete.gameObject.SetActive(false);
                    }
                }
            }
        }
        else if (Autocomplete.gameObject.activeInHierarchy)
        {
            Autocomplete.gameObject.SetActive(false);
        }
        if (Tabs[3].activeInHierarchy)
        {
            UpdateGlobalVariable();
        }
    }
コード例 #18
0
 void ReceiveChatMessage(int id, string msg)
 {
     ConsoleScript.Log(PlayerListScript.Instance().GetPlayerInfoList()[id].name_ + ": " + msg);
     PlayRandomSound(chat_sounds, 0.6f);
 }
コード例 #19
0
    public List <string> GetAutocompleteOptions()
    {
        ConsoleScript c        = Target.GetComponent <ConsoleScript>();
        string        textpart = GetTextAfterCaret(scriptInputField.text, CursorPosition);

        if (string.IsNullOrEmpty(textpart))
        {
            textpart = " ";
        }

        bool EmptyLine = true;
        int  autos     = GetIndexAfterCaret(scriptInputField.text, CursorPosition) + 1;

        if (CursorPosition - 1 > 0)
        {
            if (CursorPosition - autos >= 0 && CursorPosition - autos < scriptInputField.text.Length)
            {
                if (scriptInputField.text[CursorPosition - autos] == '.')
                {
                    EmptyLine = false;
                }
            }
            else
            {
                EmptyLine = true;
            }
        }
        else
        {
            EmptyLine = true;
        }

        List <string> AutocompleteResult = new List <string>();

        if (EmptyLine)
        {
            for (int k = 0; k < c.Keyword.Length; k++)
            {
                if (c.Keyword[k].StartsWith(textpart) || (string.IsNullOrWhiteSpace(textpart) && InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)))
                {
                    AutocompleteResult.Add(c.Keyword[k]);
                }
            }
            for (int k = 0; k < c.transmitter.sources.Count; k++)
            {
                if (c.transmitter.sources[k].Name.StartsWith(textpart) || (string.IsNullOrWhiteSpace(textpart) && InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)))
                {
                    AutocompleteResult.Add(c.transmitter.sources[k].Name);
                }
            }
            for (int k = 0; k < c.GlobalVariable.Count; k++)
            {
                if (c.GlobalVariable[k].Id.StartsWith(textpart) || (string.IsNullOrWhiteSpace(textpart) && InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)))
                {
                    AutocompleteResult.Add(c.GlobalVariable[k].Id);
                }
            }
            for (int k = 0; k < c.GlobalFunctionNames.Count; k++)
            {
                if (c.GlobalFunctionNames[k].StartsWith(textpart) || (string.IsNullOrWhiteSpace(textpart) && InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)))
                {
                    AutocompleteResult.Add(c.GlobalFunctionNames[k]);
                }
            }
        }

        if (CursorPosition - 1 > 0)
        {
            //TODO: Transmitter variable/functions
            //Get the previous transmitter source name
            //Drain info from it
            int autosegment = GetIndexAfterCaret(scriptInputField.text, CursorPosition) + 1;
            if (CursorPosition - autosegment >= 0 && CursorPosition - autosegment < scriptInputField.text.Length)
            {
                if (scriptInputField.text[CursorPosition - autosegment] == '.')
                {
                    string SourceName = GetTextAfterCaret(scriptInputField.text, CursorPosition - autosegment);

                    List <FunctionTemplate> externalFunctions = new List <FunctionTemplate>();
                    c.transmitter.AccessAllInteractableFunction(SourceName, out externalFunctions);
                    for (int k = 0; k < externalFunctions.Count; k++)
                    {
                        if (externalFunctions[k].Name.StartsWith(textpart) || (string.IsNullOrWhiteSpace(textpart) && InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)))
                        {
                            AutocompleteResult.Add(externalFunctions[k].Name);
                        }
                    }

                    List <Variable> externalVariable = new List <Variable>();
                    c.transmitter.AccessAllInteractableVariables(SourceName, out externalVariable);
                    for (int k = 0; k < externalVariable.Count; k++)
                    {
                        if (externalVariable[k].Id.StartsWith(textpart) || (string.IsNullOrWhiteSpace(textpart) && InputControl.GetInput(InputControl.InputType.CodingInputFieldShowAutocomplete)))
                        {
                            AutocompleteResult.Add(externalVariable[k].Id);
                        }
                    }
                }
            }
        }

        return(AutocompleteResult);
    }
コード例 #20
0
    void Update()
    {
        if (current_song_ != target_song_)
        {
            if (music_.volume == 0.0f)
            {
                current_song_ = target_song_;
                if (current_song_ != -1)
                {
                    music_.clip = songs[current_song_];
                }
                else
                {
                    music_.Stop();
                }
            }
            else
            {
                music_.volume = Mathf.Max(0.0f, music_.volume - Time.deltaTime);
            }
        }
        else if (current_song_ != -1)
        {
            music_.volume = Mathf.Min(MAX_SONG_VOLUME, music_.volume + Time.deltaTime);
        }
        if (!music_.isPlaying)
        {
            music_.Play();
        }
        NetEvent net_event = NetEventScript.Instance().GetEvent();

        while (net_event != null)
        {
            switch (net_event.type())
            {
            case NetEvent.Type.SERVER_INITIALIZED:
                NetEventServerInitialized();
                break;

            case NetEvent.Type.CONNECTED_TO_SERVER:
                NetEventConnectedToServer();
                break;

            case NetEvent.Type.FAILED_TO_CONNECT:
                NetEventFailedToConnect(net_event);
                break;

            case NetEvent.Type.FAILED_TO_CONNECT_TO_MASTER_SERVER:
                NetEventFailedToConnectToMasterServer(net_event);
                break;

            case NetEvent.Type.MASTER_SERVER_EVENT:
                NetEventMasterServerEvent(net_event);
                break;

            case NetEvent.Type.PLAYER_CONNECTED:
                ConsoleScript.Log("Player " + net_event.network_player() + " connected");
                networkView.RPC("SyncSongWithServer", RPCMode.Others, int.Parse(net_event.network_player().ToString()), current_song_, target_song_, music_.volume, music_.time);
                break;

            case NetEvent.Type.PLAYER_DISCONNECTED:
                NetEventPlayerDisconnected(net_event);
                break;

            case NetEvent.Type.DISCONNECTED_FROM_SERVER:
                NetEventDisconnectedFromServer(net_event);
                break;
            }
            net_event = NetEventScript.Instance().GetEvent();
        }
    }
コード例 #21
0
 // Chain of parallel functions for AutoJoin
 void RequestPageURLForAutoJoin()
 {
     ConsoleScript.Log("Requesting page url");
     Application.ExternalEval("GetUnity().SendMessage(\"GlobalScriptObject\", \"ReceivePageURLForAutoJoin\", decodeURIComponent(document.location.href));");
 }
コード例 #22
0
ファイル: CameraControl.cs プロジェクト: shldn/assembly
    }     // End of Start().

    void Update()
    {
        // Smoothly interpolate camera position/rotation.
        transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref smoothVelTranslate, translateSmoothTime);
        Quaternion tempRot = transform.rotation;

        tempRot            = Quaternion.Slerp(tempRot, targetRot, 5 * Time.deltaTime);
        transform.rotation = tempRot;

        // Toggle camera lock/free movement with Spacebar.
        if (WesInput.GetKey("Camera Lock") && !spacePressed)
        {
            spacePressed = true;
            cameraLock   = !cameraLock;
        }

        // Toggle freelook/camera lock.
        if (!WesInput.GetKey("Camera Lock"))
        {
            spacePressed = false;
        }

        // Camera defaults to unfocused, but if an element is selected this will become true.
        cameraFocused = false;

        // Determine what the user is looking at.
        Ray        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit cameraLookHit;

        lookedAtNode = null;
        if (Physics.Raycast(mouseRay, out cameraLookHit))
        {
            lookedAtObject = cameraLookHit.transform.gameObject;
            lookedAtNode   = lookedAtObject.GetComponent <Node>();
        }
        else
        {
            lookedAtObject = null;
        }

        // When not in free-look mode...
        if (cameraLock)
        {
            Screen.lockCursor = false;

            if (selectedAssembly != null)
            {
                cameraFocused = true;
                focusedPos    = selectedAssembly.GetCenter();
            }

            if (selectedNode != null)
            {
                cameraFocused = true;
                focusedPos    = selectedNode.transform.position;
            }

            // Rotate orbit via directional input.
            if (Input.GetMouseButton(1))
            {
                targetRot *= Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * cameraRotateSpeed, -Vector3.right);
                targetRot *= Quaternion.AngleAxis(Input.GetAxis("Mouse X") * cameraRotateSpeed, Vector3.up);
            }

            // If we are focusing on some object...
            if (cameraFocused)
            {
                // Zoom orbit with mousewheel.
                orbitDist -= (orbitDist * 0.3f) * Input.GetAxis("Mouse ScrollWheel") * orbitZoomSpeed;
                orbitDist  = Mathf.Clamp(orbitDist, 3f, Mathf.Infinity);

                targetPos = focusedPos - (targetRot * (Vector3.forward * orbitDist));
            }
            // If camera is locked but not focused...
            else
            {
                // Move in/out with mousewheel.
                targetPos += Camera.main.transform.forward * Input.GetAxis("Mouse ScrollWheel") * orbitZoomSpeed;
            }


            if (lookedAtObject)
            {
                if (lookedAtNode && Input.GetMouseButtonDown(0))
                {
                    mouseClickedNode = lookedAtNode;
                }
                else if (lookedAtNode && Input.GetMouseButtonUp(0))
                {
                    mouseReleasedNode = lookedAtNode;
                }

                // 'Selecting' a single node.
                if (mouseReleasedNode && (mouseClickedNode == mouseReleasedNode))
                {
                    Node clickAndReleaseNode = mouseReleasedNode;
                    // Select the assembly attached to the node, if applicable...
                    if ((clickAndReleaseNode.assembly != null) && (selectedAssembly != clickAndReleaseNode.assembly) && (!selectedNode || (selectedNode == clickAndReleaseNode) || (clickAndReleaseNode.assembly != selectedNode.assembly)))
                    {
                        selectedNode = null;
                        FocusOnAssembly(clickAndReleaseNode.assembly);
                    }
                    // Otherwise just select the node.
                    else
                    {
                        selectedNode     = clickAndReleaseNode;
                        selectedAssembly = null;
                        targetRot        = Quaternion.LookRotation(selectedNode.transform.position - transform.position, Camera.main.transform.up);
                    }
                }
            }


            // Create a new bond.
            if (mouseClickedNode && mouseReleasedNode && !mouseClickedNode.BondedTo(mouseReleasedNode) && (mouseClickedNode != mouseReleasedNode) && (mouseClickedNode.BondCount() < 3) && (mouseReleasedNode.BondCount() < 3))
            {
                new Bond(mouseClickedNode, mouseReleasedNode);
                ConsoleScript.NewLine("Manually created a bond.");
            }
            // Destroy an existing bond.
            else if (mouseClickedNode && mouseReleasedNode && mouseClickedNode.BondedTo(mouseReleasedNode))
            {
                mouseClickedNode.GetBondTo(mouseReleasedNode).Destroy();
                ConsoleScript.NewLine("Manually removed a bond.");
            }
        }
        // If we're in free-look mode...
        else
        {
            Screen.lockCursor = true;
            lookedAtObject    = null;
            selectedNode      = null;
            selectedAssembly  = null;

            // Pitch/yaw camera via mouse movement.
            targetRot *= Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * cameraRotateSpeed, -Vector3.right);
            targetRot *= Quaternion.AngleAxis(Input.GetAxis("Mouse X") * cameraRotateSpeed, Vector3.up);
        }

        // Roll camera using Q and E
        targetRot *= Quaternion.AngleAxis(WesInput.rotationThrottle * -cameraRotateSpeed, Vector3.forward);

        if (!cameraFocused)
        {
            // Navigation
            // Translate position with keyboard input.
            targetPos += WesInput.forwardThrottle * transform.forward * cameraMoveSpeed * Time.deltaTime;
            targetPos += WesInput.horizontalThrottle * transform.right * cameraMoveSpeed * Time.deltaTime;
            targetPos += WesInput.verticalThrottle * transform.up * cameraMoveSpeed * Time.deltaTime;
        }


        // Auto-orbit
        targetRot = Quaternion.RotateTowards(targetRot, targetRot * autoOrbit, Time.deltaTime * 2.5f);


        if (Input.GetMouseButtonUp(0))
        {
            mouseClickedNode  = null;
            mouseReleasedNode = null;
        }

        dragLineRenderer.enabled = false;
        if (mouseClickedNode && lookedAtNode)
        {
            dragLineRenderer.SetPosition(0, mouseClickedNode.transform.position);
            dragLineRenderer.SetPosition(1, lookedAtNode.transform.position);

            if (mouseClickedNode.BondedTo(lookedAtNode))
            {
                dragLineRenderer.SetColors(Color.yellow, Color.red);
                dragLineRenderer.enabled = true;
            }
            else if ((mouseClickedNode.BondCount() < 3) && (lookedAtNode.BondCount() < 3))
            {
                dragLineRenderer.SetColors(Color.green, Color.white);
                dragLineRenderer.enabled = true;
            }
        }
    } // End of Update().