예제 #1
0
            public static void PlayerHumanScript_OnIntClassChange(PlayerHumanScript self, PlayerHumanScript.PlayerClass change)
            {
                if (!self.isServer)
                {
                    self.NetworkcurrentClass = change;
                }
                if (change == PlayerHumanScript.PlayerClass.Commando)
                {
                    self.navMapMark.SetActive(false);
                }
                if (!self.isLocalPlayer || change == PlayerHumanScript.PlayerClass.Undefined)
                {
                    return;
                }
                int playerCount = UnityEngine.Object.FindObjectsOfType <LobbyPlayerScript>().Length;

                if (NetworkedGameManagerScript._instance.RandomSpawns)
                {
                    self.wpnmgr.PresetWeaponAdd(16, 6, 1);
                }
                if (NetworkedGameManagerScript._instance.RandomItems)
                {
                    int num2 = UnityEngine.Random.Range(1, 5);
                    for (int i = 0; i < num2; i++)
                    {
                        self.wpnmgr.PresetWeaponAdd(UnityEngine.Random.Range(1, self.IdItemObjects.Length), i, UnityEngine.Random.Range(1, 5));
                    }
                }
                else
                {
                    switch (change)
                    {
                    case PlayerHumanScript.PlayerClass.Recon:
                        //Slot0
                        if (ReconLoadout[0].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)ReconLoadout[0].ItemId,
                                0,
                                ReconLoadout[0].AmmoBase + ReconLoadout[0].AmmoDiv / playerCount + ReconLoadout[0].AmmoMul * playerCount);
                        }
                        //Slot1
                        if (ReconLoadout[1].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)ReconLoadout[1].ItemId,
                                1,
                                ReconLoadout[1].AmmoBase + ReconLoadout[1].AmmoDiv / playerCount + ReconLoadout[1].AmmoMul * playerCount);
                        }
                        //Slot2
                        if (ReconLoadout[2].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)ReconLoadout[2].ItemId,
                                2,
                                ReconLoadout[2].AmmoBase + ReconLoadout[2].AmmoDiv / playerCount + ReconLoadout[2].AmmoMul * playerCount);
                        }
                        //Slot3
                        if (ReconLoadout[3].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)ReconLoadout[3].ItemId,
                                3,
                                ReconLoadout[3].AmmoBase + ReconLoadout[3].AmmoDiv / playerCount + ReconLoadout[3].AmmoMul * playerCount);
                        }
                        //Slot4
                        if (ReconLoadout[4].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)ReconLoadout[4].ItemId,
                                4,
                                ReconLoadout[4].AmmoBase + ReconLoadout[4].AmmoDiv / playerCount + ReconLoadout[4].AmmoMul * playerCount);
                        }
                        break;

                    case PlayerHumanScript.PlayerClass.Assault:
                        //Slot0
                        if (RiflemanLoadout[0].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)RiflemanLoadout[0].ItemId,
                                0,
                                RiflemanLoadout[0].AmmoBase + RiflemanLoadout[0].AmmoDiv / playerCount + RiflemanLoadout[0].AmmoMul * playerCount);
                        }
                        //Slot1
                        if (RiflemanLoadout[1].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)RiflemanLoadout[1].ItemId,
                                1,
                                RiflemanLoadout[1].AmmoBase + RiflemanLoadout[1].AmmoDiv / playerCount + RiflemanLoadout[1].AmmoMul * playerCount);
                        }
                        //Slot2
                        if (RiflemanLoadout[2].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)RiflemanLoadout[2].ItemId,
                                2,
                                RiflemanLoadout[2].AmmoBase + RiflemanLoadout[2].AmmoDiv / playerCount + RiflemanLoadout[2].AmmoMul * playerCount);
                        }
                        //Slot3
                        if (RiflemanLoadout[3].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)RiflemanLoadout[3].ItemId,
                                3,
                                RiflemanLoadout[3].AmmoBase + RiflemanLoadout[3].AmmoDiv / playerCount + RiflemanLoadout[3].AmmoMul * playerCount);
                        }
                        //Slot4
                        if (RiflemanLoadout[4].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)RiflemanLoadout[4].ItemId,
                                4,
                                RiflemanLoadout[4].AmmoBase + RiflemanLoadout[4].AmmoDiv / playerCount + RiflemanLoadout[4].AmmoMul * playerCount);
                        }
                        break;

                    case PlayerHumanScript.PlayerClass.Medic:
                        //Slot0
                        if (MedicLoadout[0].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)MedicLoadout[0].ItemId,
                                0,
                                MedicLoadout[0].AmmoBase + MedicLoadout[0].AmmoDiv / playerCount + MedicLoadout[0].AmmoMul * playerCount);
                        }
                        //Slot1
                        if (MedicLoadout[1].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)MedicLoadout[1].ItemId,
                                1,
                                MedicLoadout[1].AmmoBase + MedicLoadout[1].AmmoDiv / playerCount + MedicLoadout[1].AmmoMul * playerCount);
                        }
                        //Slot2
                        if (MedicLoadout[2].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)MedicLoadout[2].ItemId,
                                2,
                                MedicLoadout[2].AmmoBase + MedicLoadout[2].AmmoDiv / playerCount + MedicLoadout[2].AmmoMul * playerCount);
                        }
                        //Slot3
                        if (MedicLoadout[3].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)MedicLoadout[3].ItemId,
                                3,
                                MedicLoadout[3].AmmoBase + MedicLoadout[3].AmmoDiv / playerCount + MedicLoadout[3].AmmoMul * playerCount);
                        }
                        //Slot4
                        if (MedicLoadout[4].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)MedicLoadout[4].ItemId,
                                4,
                                MedicLoadout[4].AmmoBase + MedicLoadout[4].AmmoDiv / playerCount + MedicLoadout[4].AmmoMul * playerCount);
                        }
                        break;

                    case PlayerHumanScript.PlayerClass.Commando:
                        //Slot0
                        if (CommandoLoadout[0].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)CommandoLoadout[0].ItemId,
                                0,
                                CommandoLoadout[0].AmmoBase + CommandoLoadout[0].AmmoDiv / playerCount + CommandoLoadout[0].AmmoMul * playerCount);
                        }
                        //Slot1
                        if (CommandoLoadout[1].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)CommandoLoadout[1].ItemId,
                                1,
                                CommandoLoadout[1].AmmoBase + CommandoLoadout[1].AmmoDiv / playerCount + CommandoLoadout[1].AmmoMul * playerCount);
                        }
                        //Slot2
                        if (CommandoLoadout[2].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)CommandoLoadout[2].ItemId,
                                2,
                                CommandoLoadout[2].AmmoBase + CommandoLoadout[2].AmmoDiv / playerCount + CommandoLoadout[2].AmmoMul * playerCount);
                        }
                        //Slot3
                        if (CommandoLoadout[3].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)CommandoLoadout[3].ItemId,
                                3,
                                CommandoLoadout[3].AmmoBase + CommandoLoadout[3].AmmoDiv / playerCount + CommandoLoadout[3].AmmoMul * playerCount);
                        }
                        //Slot4
                        if (CommandoLoadout[4].ItemId != Info.ItemIds.Null)
                        {
                            self.wpnmgr.PresetWeaponAdd(
                                (int)CommandoLoadout[4].ItemId,
                                4,
                                CommandoLoadout[4].AmmoBase + CommandoLoadout[4].AmmoDiv / playerCount + CommandoLoadout[4].AmmoMul * playerCount);
                        }
                        break;
                    }
                }
                GameCanvasScript._instance.ShowClassInfo(change);
            }
예제 #2
0
 private static void PlayerHumanScript_OnIntClassChange_Hook(On.PlayerHumanScript.orig_OnIntClassChange orig, PlayerHumanScript self, PlayerHumanScript.PlayerClass change)
 {
     PlayerHumanScript_OnIntClassChange(self, change);
 }