Initialize.Update C# (CSharp) Méthode

Update() public méthode

public Update ( ) : void
Résultat void
    public void Update()
    {
        if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) {
            if (Input.GetKeyDown(KeyCode.Alpha1)) {
                Movement.autoflyspeed = 0F;
                selfTransform.localPosition = UnityConstants.startingLocOne;
                trackOctant (CommonUtility.getOctantIndicesFromVector3
                    (new remap.NDNMOG.DiscoveryModule.Vector3(UnityConstants.startingLocOne.x, UnityConstants.startingLocOne.y, UnityConstants.startingLocOne.z)));
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2)) {
                Movement.autoflyspeed = 0F;
                selfTransform.localPosition = UnityConstants.startingLocTwo;
                trackOctant (CommonUtility.getOctantIndicesFromVector3
                    (new remap.NDNMOG.DiscoveryModule.Vector3(UnityConstants.startingLocTwo.x, UnityConstants.startingLocTwo.y, UnityConstants.startingLocTwo.z)));
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3)) {
                Movement.autoflyspeed = 0F;
                selfTransform.localPosition = UnityConstants.startingLocThree;
                trackOctant (CommonUtility.getOctantIndicesFromVector3
                    (new remap.NDNMOG.DiscoveryModule.Vector3(UnityConstants.startingLocThree.x, UnityConstants.startingLocThree.y, UnityConstants.startingLocThree.z)));
            }
        }

        selfLocation.x_ = selfTransform.localPosition.x;
        selfLocation.y_ = selfTransform.localPosition.y;
        selfLocation.z_ = selfTransform.localPosition.z;

        // setLocation talks with DiscoveryModule without calling callback.
        instance.getSelfGameEntity ().setLocation (selfLocation, false);
        List<string> toDelete = new List<string> ();
        // For iteration
        Transform entity;
        // Is generating a copy of hashtable a potentially better idea than this?
        hashtableLock.WaitOne ();
        foreach (DictionaryEntry pair in gameEntityHashtable) {
            entity = playersParentTransform.Find(((string)pair.Key).Replace("/", "-"));

            remap.NDNMOG.DiscoveryModule.Vector3 location = new remap.NDNMOG.DiscoveryModule.Vector3 ((remap.NDNMOG.DiscoveryModule.Vector3)pair.Value);
            //Debug.Log(location.x_);
            UnityEngine.Vector3 locationUnity = new UnityEngine.Vector3 (location.x_, location.y_, location.z_);

            if (entity == null) {
                if (locationUnity.x != Constants.DefaultLocationDropEntity && locationUnity.x != Constants.DefaultLocationNewEntity) {
                    Transform newEntity = Instantiate (playerTransform, locationUnity, Quaternion.identity) as Transform;
                    newEntity.name = ((string)pair.Key).Replace("/", "-");
                    newEntity.parent = GameObject.Find(UnityConstants.playerParentPath).transform;
                    newEntity.Find(UnityConstants.labelTransformPath.TrimStart('/')).guiText.text = (string)pair.Key;
                }
            } else {
                if (locationUnity.x != Constants.DefaultLocationDropEntity && locationUnity.x != Constants.DefaultLocationNewEntity) {
                    entity.transform.localPosition = locationUnity;
                } else {
                    Destroy (entity.gameObject);

                    // hashtable deletion in foreach loop is considered illegal
                    toDelete.Add ((string)pair.Key);
                }
            }
        }
        foreach (string str in toDelete) {
            gameEntityHashtable.Remove (str);
        }
        if (instantiated) {
            updateOctantList ((int)selfLocation.x_, (int)selfLocation.y_, (int)selfLocation.z_);
        }

        hashtableLock.ReleaseMutex ();

        renderListLock.WaitOne ();
        if (renderList.Count != 0) {
            // Rendering based on the list...which still tells me collection is modified, even if I have the lock to protect it...finding out why.
            foreach (EntityInfo ei in renderList) {
                GameObject renderEntity = playersParentTransform.Find(ei.name_.Replace("/", "-") + UnityConstants.dollPath).gameObject;
                if (renderEntity != null) {
                    string path = "Materials/" + ei.renderString_;
                    Material unityMaterial = Resources.Load (path, typeof(Material)) as Material;

                    if (unityMaterial != null) {
                        renderEntity.GetComponent<MeshRenderer> ().material = unityMaterial;
                    }
                }
            }

            renderList.Clear();
        }
        renderListLock.ReleaseMutex ();
    }