Exemplo n.º 1
0
        public void Initialize()
        {
            if (!NetworkServer.active)
            {
                return;
            }

            Mailbox mailbox = PartyParrotManager.Instance.Random.GetRandomEntry(_mailboxes);

            Vector3 seedPosition = Vector3.zero;

            if (null != mailbox)
            {
                seedPosition = mailbox.transform.position;
            }
            ActivateMailboxGroup(seedPosition);
        }
Exemplo n.º 2
0
        //[Server]
        private void ActivateMailboxGroup(Vector3 seedPosition)
        {
            Assert.IsTrue(NetworkServer.active);

            _seedPosition = seedPosition;
            Debug.Log($"Seeding mailboxes at {_seedPosition}");

            Profiler.BeginSample("MailboxManager.ActivateMailboxGroup");
            try {
                _previousActiveMailboxes.ForEach(x => x.Reset());
                _previousActiveMailboxes.Clear();

                // get the seed mailbox
                _seedBox = GetSeedMailbox(_seedPosition);
                if (null == _seedBox)
                {
                    Debug.LogWarning("No seed mailbox found!");
                    return;
                }

                // Activate the seed box
                SpawnMailbox(_seedBox);

                // Get boxes in range of the seed for the set
                List <Mailbox> foundBoxes = GetValidMailboxesInRange(_seedBox.transform.position, _mailboxData.SetMinRange, _mailboxData.SetMaxRange);

                // Select & activate the rest of the required boxes
                int setSize = PartyParrotManager.Instance.Random.Next(_mailboxData.SetCountMin, _mailboxData.SetCountMax);     // NOTE: not SetCountMax - 1 because we spawend the seed already
                while (setSize > 0 && foundBoxes.Count > 0)
                {
                    Mailbox box = PartyParrotManager.Instance.Random.RemoveRandomEntry(foundBoxes);
                    SpawnMailbox(box);
                    setSize--;
                }

                _previousActiveMailboxes.AddRange(_activeMailboxes);
                _currentSetSize = _activeMailboxes.Count;
            } finally {
                Profiler.EndSample();
            }
        }
Exemplo n.º 3
0
 public void UnregisterMailbox(Mailbox mailbox)
 {
     _mailboxes.Remove(mailbox);
 }
Exemplo n.º 4
0
 public void RegisterMailbox(Mailbox mailbox)
 {
     _mailboxes.Add(mailbox);
 }