Пример #1
0
 private void HandleGeneralUpdate(int index, DemoCoder decoder)
 {
     if (index == 0)
     {
         Henge henge = GameObject.FindObjectOfType <Henge>();
         henge.SetRuneState(decoder.GetPortalRunes(index, henge.getSize()));
         henge.transform.position = decoder.GetPosition(index);
         henge.transform.rotation = decoder.GetRotation(index);
     }
     else
     {
         GameObject instance;
         int        id = decoder.GetID(index);
         networkedObjects.TryGetValue(id, out instance);
         EnemyHealth eh = instance.GetComponent <EnemyHealth>();
         if (eh != null)
         {
             //keeps track of networked and local at the same time
             int currentHealth   = eh.GetHealth();
             int networkedHealth = decoder.GetEnemyHealth(index) - eh.transientHealthLoss;
             //don't reset transient, since this may still need to be transmitted
             eh.SetHealth(Math.Min(currentHealth, networkedHealth));
         }
         else
         {
             Debug.LogError("Couldn't find enemy health tracking from network id" + id);
         }
         instance.transform.position = decoder.GetPosition(index);
         instance.transform.rotation = decoder.GetRotation(index);
     }
 }