Ejemplo n.º 1
0
 public static WeaponDatabase GetInstance()
 {
     if (instance == null)
     {
         instance = new WeaponDatabase();
     }
     return(instance);
 }
Ejemplo n.º 2
0
 public void NetUpdate()
 {
     if (otherPlayer != null && otherPlayerLastData != null)
     {
         otherPlayer.transform.position   = Vector3.Lerp(otherPlayer.transform.position, otherPlayerLastData.Position, Time.deltaTime * 15);
         otherPlayer.transform.rotation   = Quaternion.Lerp(otherPlayer.transform.rotation, Quaternion.Euler(otherPlayerLastData.Rotation), Time.deltaTime * 40);
         otherPlayer.transform.localScale = otherPlayerLastData.Size;
         otherPlayer.Name = otherPlayerLastData.Name;
         otherPlayer.name = otherPlayerLastData.Name;
         otherPlayer.Animator.SetTrigger(otherPlayerLastData.CurrentAnimation);
         otherPlayer.Look(otherPlayerLastData.LookingPos);
         foreach (StatData stat in otherPlayerLastData.ActorStats)
         {
             otherPlayer.GetStat(stat.Name).Set(stat.Value);
         }
         if (otherPlayer.EquipedWeapon != null)
         {
             if (otherPlayer.EquipedWeapon.Settings.Id != otherPlayerLastData.EquipedWeaponId)
             {
                 Weapon weaponInInventory = otherPlayer.GetWeaponById(otherPlayerLastData.EquipedWeaponId);
                 if (weaponInInventory == null)
                 {
                     Weapon weapon = Instantiate(
                         WeaponDatabase.GetInstance().GetWeapon(otherPlayerLastData.EquipedWeaponId).Prefab,
                         otherPlayer.transform.position,
                         Quaternion.identity).GetComponent <Weapon>();
                 }
                 else
                 {
                     otherPlayer.EquipWeapon(weaponInInventory);
                 }
             }
         }
         else
         {
             if (otherPlayerLastData.EquipedWeaponId != -1)
             {
                 MainManager.Instance.SpawnWeapon(WeaponDatabase.GetInstance().GetWeapon(
                                                      otherPlayerLastData.EquipedWeaponId).Prefab, otherPlayer.transform.position);
             }
         }
     }
 }