Ejemplo n.º 1
0
        private void WorldHostUpdate()
        {
            List <Character.Factions> teamsLeft = PlayerManager.Instance.GetRemainingTeams();

            if (teamsLeft.Count() < 2)
            {
                string winners = teamsLeft[0].ToString();
                if (!winners.EndsWith("s"))
                {
                    winners += "s";
                }
                PvP.Instance.StopGameplay(winners + " have won!");
            }

            if (LastSupplyDropTime <= 0 || Time.time - LastSupplyDropTime > SupplyDropInterval)
            {
                LastSupplyDropTime = Time.time;
                SupplyDropCounter++;

                StartCoroutine(GenerateSupplyDrops());
            }

            if (Time.time - LastEnemySpawnTime > EnemyDropInterval && EnemyCharacters.Count() > 0)
            {
                LastEnemySpawnTime = Time.time;

                Character c    = null;
                var       list = EnemyCharacters.Where(x => !x.gameObject.activeSelf).ToList();

                if (list.Count() > 0)
                {
                    var butcher = list.Find(x => x.Name.ToLower().Contains("butcher"));

                    if (SupplyDropCounter < 3 || !butcher)
                    {
                        if (butcher)
                        {
                            list.Remove(butcher);
                        }
                        int random = UnityEngine.Random.Range(0, list.Count());
                        c = list.ElementAt(random);
                    }
                    else
                    {
                        c = butcher; // time to spawn the Butcher of Men!
                    }

                    if (c)
                    {
                        if (c.IsDead)
                        {
                            c.Resurrect();
                        }

                        string  scene     = SceneManagerHelper.ActiveSceneName;
                        var     spawnlist = Templates.BR_Templates.SpawnLocations[scene];
                        int     random    = UnityEngine.Random.Range(0, spawnlist.Count());
                        Vector3 loc       = spawnlist[random];

                        if (PhotonNetwork.offlineMode)
                        {
                            RPCManager.Instance.SendSpawnEnemyRPC(c.UID.ToString(), loc.x, loc.y, loc.z);
                        }
                        else
                        {
                            RPCManager.Instance.photonView.RPC("SendSpawnEnemyRPC", PhotonTargets.All, new object[] { c.UID.ToString(), loc.x, loc.y, loc.z });
                        }

                        // send butcher message
                        if (c.Name.ToLower().Contains("butcher"))
                        {
                            RPCManager.SendMessageToAll("The Butcher of Men has spawned!");
                            EnemyCharacters.RemoveAll(x => x.UID == butcher.UID);
                        }

                        // change faction to NONE
                        PlayerManager.Instance.ChangeFactions(c, Character.Factions.NONE);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private IEnumerator GenerateSupplyDrops()
        {
            //OLogger.Warning("generating supply drops!");

            if (ActiveItemContainers.Count() > 0)
            {
                if (PhotonNetwork.offlineMode)
                {
                    RPCManager.Instance.RPCSendCleanup();
                }
                else
                {
                    RPCManager.Instance.photonView.RPC("RPCSendCleanup", PhotonTargets.All, new object[0]);
                }

                yield return(new WaitForSeconds(2f)); // wait 2 seconds after destroying the active objects, so we dont start destroying the new ones!
            }

            if (SupplyDropCounter == 1)
            {
                // first drop. generate initial supply caches for all players

                foreach (PlayerSystem ps in Global.Lobby.PlayersInLobby)
                {
                    Character     _char = ps.ControlledCharacter;
                    TreasureChest stash = ItemManager.Instance.GenerateItemNetwork(1000110).GetComponent <TreasureChest>();
                    stash.transform.position = _char.transform.position + new Vector3(1.5f, 0, 1.5f);
                    ActiveItemContainers.Add(stash.gameObject);

                    if (!PhotonNetwork.offlineMode)
                    {
                        RPCManager.Instance.photonView.RPC("RPCGenerateStash", PhotonTargets.Others, new object[]
                        {
                            stash.ItemID,
                            stash.UID,
                            stash.transform.position.x,
                            stash.transform.position.y,
                            stash.transform.position.z
                        });
                    }

                    At.Invoke(stash, "InitDrops");
                    for (int i = 0; i < 5; i++)
                    {
                        At.SetField(stash, "m_hasGeneratedContent", false);
                        stash.GenerateContents();
                    }
                }
            }
            else
            {
                RPCManager.SendMessageToAll("Supply Chests are spawning!");

                // generate chest or ornate chest
                List <Vector3> locations = Templates.BR_Templates.SupplyDropLocations[SceneManagerHelper.ActiveSceneName].ToList();

                // 1 supply drop per 2 players. minimum of 2 drops.
                int numOfDrops = (int)Math.Ceiling(PlayerManager.Instance.GetRemainingPlayers().Count() * 0.5f);
                numOfDrops = (int)Mathf.Clamp(numOfDrops, 2, locations.Count());

                //Debug.Log("Generating " + numOfDrops + " supply drops from a locations list size of " + locations.Count());
                for (int i = 0; i < numOfDrops; i++)
                {
                    if (locations.Count == 0)
                    {
                        break;
                    }

                    int random = UnityEngine.Random.Range(0, locations.Count());
                    //Debug.Log("Rolled location index " + random);
                    GenerateChestSingle(locations[random]);
                    locations.RemoveAt(random);
                }
            }
        }
Ejemplo n.º 3
0
            public static void Prefix(Character __instance)
            {
                var self = __instance;

                if (PvP.Instance.CurrentGame != PvP.GameModes.BattleRoyale)
                {
                    return;
                }

                if (!self.IsAI)
                {
                    //Debug.Log("Dropping player stuff!");
                    // custom player death (drop items)

                    if (!PhotonNetwork.isNonMasterClientInRoom && At.GetField(self, "m_lastDealers") is List <Pair <UID, float> > lastDealers)
                    {
                        float  lowest = Time.time;
                        string uid    = "";
                        foreach (var entry in lastDealers)
                        {
                            if (entry.Value < lowest)
                            {
                                lowest = entry.Value;
                                uid    = entry.Key;
                            }
                        }
                        if (uid != "" && CharacterManager.Instance.GetCharacter(uid) is Character lastDealer)
                        {
                            lastDealers.Clear();
                            At.SetField(self, "m_lastDealers", lastDealer);
                            RPCManager.SendMessageToAll(lastDealer.Name + " has defeated " + self.Name);
                        }
                    }

                    foreach (EquipmentSlot equipslot in self.Inventory.Equipment.EquipmentSlots.Where(x => x != null && x.HasItemEquipped))
                    {
                        self.Inventory.DropItem(equipslot.EquippedItem.UID);
                    }
                }
                else
                {
                    if (self.Inventory == null || self.GetComponent <LootableOnDeath>() == null)
                    {
                        return;
                    }

                    if (!self.Inventory.Pouch || !self.Inventory.Pouch.FullyInitialized)
                    {
                        self.Inventory.ProcessStart();
                    }

                    // SPECIFIC TO MONSOON MAP

                    if (!PhotonNetwork.isNonMasterClientInRoom)
                    {
                        if (self.Name.ToLower().Contains("butcher"))
                        {
                            BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_High, 3, self.Inventory.Pouch.transform);
                            BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Weapons_High, 1, self.Inventory.Pouch.transform);
                        }
                        else if (self.Name == "Immaculate" || self.name == "Shell Horror")
                        {
                            BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_High, 1, self.Inventory.Pouch.transform);
                            BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_Low, 2, self.Inventory.Pouch.transform);
                        }
                        else
                        {
                            BattleRoyale.Instance.AddItemsToContainer(Templates.BR_Templates.Skills_Low, 3, self.Inventory.Pouch.transform);
                        }
                    }
                }

                if (__instance.IsLocalPlayer)
                {
                    // begin spectate
                    __instance.OwnerPlayerSys.gameObject.AddComponent <Spectate>();
                }
            }