Пример #1
0
    private void Awake()
    {
        MultiplayerManager.PacketEvt += PacketHandler;
        enemies = new ObjSyncList <BaseEnemy>(null);

        // Assign ids to the objects
        BaseEnemy[] enemyList = FindObjectsOfType <BaseEnemy>();
        byte        i         = 3;

        foreach (BaseEnemy enemy in enemyList)
        {
            enemy.AssignId(i);
            enemies.Add(enemy);
            i++;
        }
    }
    private void Awake()
    {
        MultiplayerManager.PacketEvt += PacketHandler;
        interactables = new ObjSyncList <Interactable>(null);

        // Assign ids to the objects
        Interactable[] interactableList = FindObjectsOfType <Interactable>();
        byte           i = 0;

        foreach (Interactable interactable in interactableList)
        {
            interactable.AssignId(i);
            interactables.Add(interactable);
            i++;
        }
    }
Пример #3
0
    public void OnEnable()
    {
        MultiplayerManager.PacketEvt += RecieveConnection;
        PhysicsManager.PhysicsEvt    += PhysicsHandler;

        objects      = new ObjSyncList <PhysicsObject>(null);
        movedObjList = new ObjSyncList <PhysicsObject>(null);

        // Assign ids to the objects
        PhysicsObject[] objList = FindObjectsOfType <PhysicsObject>();
        byte            i       = 0;

        foreach (PhysicsObject obj in objList)
        {
            obj.AssignId(i);
            objects.Add(obj);
            i++;
        }
    }
Пример #4
0
    public void OnEnable()
    {
        UpdatePlayerList(MultiplayerManager.peerManager.PrintAllPeers());
        UpdateListeningPort();

        MultiplayerManager.PacketEvt     += RecievePacket;
        MultiplayerManager.DisconnectEvt += Disconnection;

        selectorList = new ObjSyncList <PlayerSelector>(SpawnPlayerSelector(MultiplayerManager.LocalId));

        if (!MultiplayerManager.IsHost)
        {
            MultiplayerManager.peerManager.GetHostPeer().SendData(
                selectorList.localInstance.GetByteData(),
                PacketType.charSelect,
                PacketValue.addUpdate,
                true);
        }
    }
Пример #5
0
    public void SpawnAllPlayer()
    {
        cachedSelectors.TryGetValue(MultiplayerManager.LocalId, out int type);
        BasePlayer localPlayer = SpawnPlayer((PlayerType)type, MultiplayerManager.LocalId);

        players = new ObjSyncList <BasePlayer>(localPlayer);
        Camera.main.transform.SetParent(localPlayer.transform, false);

        for (byte i = 0; i < cachedSelectors.Count; i++)
        {
            if (i != MultiplayerManager.LocalId)
            {
                cachedSelectors.TryGetValue(i, out int otherType);
                players.Add(SpawnPlayer((PlayerType)otherType, i));
            }
        }

        cachedSelectors.Clear();
        MultiplayerManager.PacketEvt     += RecieveConnection;
        MultiplayerManager.DisconnectEvt += Disconnection;
    }
Пример #6
0
 private void Awake()
 {
     MultiplayerManager.PacketEvt += PacketHandler;
     projectiles = new ObjSyncList <Projectile>(null);
     StartCoroutine(DestroyFlaggedProjectiles());
 }