예제 #1
0
        public void RpcRemoveUnit(uint unitNetId)
        {
            NetworkIdentity identity;

            if (NetworkIdentity.spawned.TryGetValue(unitNetId, out identity))
            {
                UnitDispatcher unit = identity.GetComponent <UnitDispatcher>();
                RemoveUnit(unit);
            }
        }
예제 #2
0
        /// <summary>
        ///     Call this to notify when a unit is destroyed
        ///     or otherwise removed from the platoon.
        /// </summary>
        public void RemoveUnit(UnitDispatcher unit)
        {
            Units.Remove(unit);
            GhostPlatoon.RemoveOneGhostUnit();

            if (Units.Count == 0)
            {
                Destroy(gameObject);
                MatchSession.Current.RegisterPlatoonDeath(this);
            }
        }
예제 #3
0
        public void RpcEstablishReferences(
            uint ghostPlatoonNetId, uint[] unitNetIds)
        {
            NetworkIdentity identity;

            if (NetworkIdentity.spawned.TryGetValue(ghostPlatoonNetId, out identity))
            {
                GhostPlatoon = identity.gameObject.GetComponent <GhostPlatoonBehaviour>();
            }

            // Also find, augment and link to the units:
            foreach (uint unitNetId in unitNetIds)
            {
                if (NetworkIdentity.spawned.TryGetValue(unitNetId, out identity))
                {
                    UnitDispatcher unit = identity.GetComponent <UnitDispatcher>();
                    AddSingleExistingUnit(unit);
                }
            }
        }
예제 #4
0
 /// <summary>
 ///     Meant to put already existing units into the platoon
 ///     (such as when merging or splitting platoons).
 /// </summary>
 /// <param name="realUnit"></param>
 public void AddSingleExistingUnit(UnitDispatcher realUnit)
 {
     GhostPlatoon.AddSingleUnit();
     Units.Add(realUnit);
 }