void CalculateDropChance() { Data_PlayerFile_Sr zombie = RoomsManager.GetPlayerData(index); int dropID = 0; if (zombie.HPMax >= 100) { dropID = 2; if (zombie.HPMax >= 200) { dropID = Random.Range(2, 3); } if (zombie.HPMax >= 300) { dropID = Random.Range(3, 4); } float chance = zombie.HPMax * zombie.attackPower / (float)dropID / 1000; Random.seed = (int)Time.time; float var1 = Random.value; Random.seed = (int)Time.time * Random.Range(3, 7); float var2 = Random.value; if (Mathf.Abs(var1 - var2) < chance) { AccountData acc = Networking_OnConnect.GetAccountData(index); Player_Weapon_Sr weap = RoomsManager.InstantiateWeapon((weaponType_Sr)dropID, transform.position, acc.roomID); weap.DropWeapon(true); } } }
/// <summary> /// Player drop weapon if he have him /// </summary> public void DropWeapon() { if (weaponOnMe) { weaponOnMe.DropWeapon(true); Message_Sr.DropWeapon_Sr dropped = new Message_Sr.DropWeapon_Sr(); dropped.index = index; RoomsManager.SendReliableAtRoom(Networking_msgType_Sr.DropWeapon, dropped, index); } }