Пример #1
0
        void updateSection()
        {
            if (!PhotonNetwork.isMasterClient)
            {
                print("not master");
                return;
            }

            if (TotalEnemiesPool > 0)
            {
                //if there's any enemy left, spawn
                if (AIStatusHandler.Get_PVs(true).Count < _enemiesAtOnce)
                {
                    int aiToSpawn = Mathf.Clamp(_enemiesAtOnce - AIStatusHandler.Get_PVs(true).Count, 0, Mathf.Min(TotalEnemiesPool, 4));
                    _NPCSpawners.Shuffle();
                    foreach (var s in _NPCSpawners)
                    {
                        //Spawn if ready
                        if (s.IsAvailable && aiToSpawn > 0)
                        {
//							print ("current alive AIs : " + AIStatusHandler.Get_PVs (true).Count + ", spawning : " + aiToSpawn);
                            s.Spawn(aiToSpawn);
                            //deduct once spawned
                            TotalEnemiesPool -= aiToSpawn;
                            return;
                        }
                    }
                }
            }
            else
            {
//				print ("pool empty");
                EndEvent();
            }
        }
Пример #2
0
        protected override void checkCondition()
        {
            if (_spawner.TotalEnemiesPool < 1 && AIStatusHandler.Get_PVs(true).Count <= _AIAliveCount)
            {
                //condition met
//				print ("enemy count < 1");
                triggerNext();
            }
            else
            {
//				print (_spawner.TotalEnemiesPool + ", " + AIStatusHandler.Get_PVs (true).Count);
            }
        }
Пример #3
0
    /// <summary>
    /// Called after switching to a new MasterClient when the current one leaves.
    /// </summary>
    /// <remarks>This is not called when this client enters a room.
    /// The former MasterClient is still in the player list when this method get called.</remarks>
    /// <param name="newMasterClient">New master client.</param>
    public override void OnMasterClientSwitched(PhotonPlayer newMasterClient)
    {
        base.OnMasterClientSwitched(newMasterClient);

//		print ("Master switched, otherplayercount : " + PhotonNetwork.otherPlayers.Length);

        //transfer ownerhsip of this AI to the new master
        foreach (var pv in AIStatusHandler.Get_PVs())
        {
            pv.TransferOwnership(newMasterClient);
            print("Ownership transferred");
        }
//		}
    }