Exemplo n.º 1
0
        void OnGameStarted()
        {
            SyncManagedBehaviour.OnGameStarted(generalBehaviours, behaviorsByPlayer);
            //instance.scheduler.UpdateAllCoroutines();

            CheckQueuedBehaviours();
        }
Exemplo n.º 2
0
        private SyncManagedBehaviour NewManagedBehaviour(ISyncBehaviour b)
        {
            SyncManagedBehaviour behaviour = new SyncManagedBehaviour(b);

            mapManagedBehaviors[b] = behaviour;

            return(behaviour);
        }
Exemplo n.º 3
0
        void GetLocalData(InputDataBase playerInputData)
        {
            SyncInput.CurrentInputData = (InputData)playerInputData;

            if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
            {
                List <SyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                for (int i = 0; i < managedBehavioursByPlayer.Count; i++)
                {
                    SyncManagedBehaviour bh = managedBehavioursByPlayer[i];

                    if (bh != null && !bh.disabled)
                    {
                        bh.OnSyncedInput();
                    }
                }
            }

            SyncInput.CurrentInputData = null;
        }
Exemplo n.º 4
0
        private void InitBehaviours(bool realOwnerId)
        {
            foreach (var player in lockstep.players.Values)
            {
                List <SyncManagedBehaviour> behaviorsInstatiated = new List <SyncManagedBehaviour>();

                //:ToDo
                for (int i = 0; i < PlayerObjects.Length; i++)
                {
                    GameObject prefab = PlayerObjects[i];

                    GameObject prefabInst = GameObject.Instantiate(prefab);

                    InitializeGameObject(prefabInst, prefabInst.transform.position.ToTSVector(), prefabInst.transform.rotation.ToTSQuaternion());

                    SyncBehaviour[] behaviours = prefabInst.GetComponentsInChildren <SyncBehaviour>();

                    for (int j = 0; j < behaviours.Length; j++)
                    {
                        SyncBehaviour behaviour = behaviours[j];

                        behaviour.owner           = player.playerInfo;
                        behaviour.localOwner      = lockstep.LocalPlayer.playerInfo;
                        behaviour.numberOfPlayers = lockstep.players.Count;
                        if (realOwnerId)
                        {
                            behaviour.ownerIndex = behaviour.owner.Id;
                        }

                        SyncManagedBehaviour managedBehaviour = NewManagedBehaviour(behaviour);
                        managedBehaviour.owner      = behaviour.owner;
                        managedBehaviour.localOwner = behaviour.localOwner;

                        behaviorsInstatiated.Add(managedBehaviour);
                    }
                }

                behaviorsByPlayer.Add(player.ID, behaviorsInstatiated);
            }
        }
Exemplo n.º 5
0
 void OnGameUnPaused()
 {
     SyncManagedBehaviour.OnGameUnPaused(generalBehaviours, behaviorsByPlayer);
     //instance.scheduler.UpdateAllCoroutines();
 }
Exemplo n.º 6
0
 void OnPlayerDisconnection(byte playerId)
 {
     SyncManagedBehaviour.OnPlayerDisconnection(generalBehaviours, behaviorsByPlayer, playerId);
 }
Exemplo n.º 7
0
        void OnStepUpdate(List <InputDataBase> allInputData)
        {
            time += lockedTimeStep;

//             if (ReplayRecord.replayMode != ReplayMode.LOAD_REPLAY)
//             {
//                 CheckGameObjectsSafeMap();
//             }

            SyncInput.SetAllInputs(null);

            for (int index = 0; index < generalBehaviours.Count; index++)
            {
                SyncManagedBehaviour bh = generalBehaviours[index];

                if (bh != null && !bh.disabled)
                {
                    bh.OnPreSyncedUpdate();
                    //instance.scheduler.UpdateAllCoroutines();
                }
            }

            for (int index = 0; index < allInputData.Count; index++)
            {
                InputDataBase playerInputData = allInputData[index];

                if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
                {
                    List <SyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                    for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                    {
                        SyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                        if (bh != null && !bh.disabled)
                        {
                            bh.OnPreSyncedUpdate();
                            //instance.scheduler.UpdateAllCoroutines();
                        }
                    }
                }
            }

            SyncInput.SetAllInputs(allInputData);

            SyncInput.CurrentSimulationData = null;
            for (int index = 0; index < generalBehaviours.Count; index++)
            {
                SyncManagedBehaviour bh = generalBehaviours[index];

                if (bh != null && !bh.disabled)
                {
                    bh.OnSyncedUpdate();
                    //instance.scheduler.UpdateAllCoroutines();
                }
            }

            for (int index = 0, length = allInputData.Count; index < length; index++)
            {
                InputDataBase playerInputData = allInputData[index];

                if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID))
                {
                    SyncInput.CurrentSimulationData = (InputData)playerInputData;

                    List <SyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID];
                    for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++)
                    {
                        SyncManagedBehaviour bh = managedBehavioursByPlayer[index2];

                        if (bh != null && !bh.disabled)
                        {
                            bh.OnSyncedUpdate();
                            //instance.scheduler.UpdateAllCoroutines();
                        }
                    }
                }

                SyncInput.CurrentSimulationData = null;
            }

            CheckQueuedBehaviours();
        }