GameObject GetPooledObject(int playerID, string tag, SyncType poolSyncType) { GameObject pooledObject = null; PlayerPool poolToTakeFrom = playerPools[playerID]; if (poolSyncType == SyncType.Synced) { if (poolToTakeFrom.syncedPoolDictionary.ContainsKey(tag)) { pooledObject = poolToTakeFrom.syncedPoolDictionary[tag].Dequeue(); poolToTakeFrom.syncedPoolDictionary[tag].Enqueue(pooledObject); } else { Debug.LogWarning($"SyncedPoolDictionary with tag {tag} doesn't exist"); } } else { if (poolToTakeFrom.unSyncedPoolDictionary.ContainsKey(tag)) { pooledObject = poolToTakeFrom.unSyncedPoolDictionary[tag].Dequeue(); poolToTakeFrom.unSyncedPoolDictionary[tag].Enqueue(pooledObject); } else { Debug.LogWarning($"UnSyncedPoolDictionary with tag {tag} doesn't exist"); } } return(pooledObject); }
public void ReleasePoolable(PlayerPool poolableObject) { this.usedObjects.Remove(poolableObject); poolableObject.Release(); poolableObject.gameObject.SetActive(false); this.availableObjects.Add(poolableObject); }
public MainWindow() { InitializeComponent(); playerPool = new PlayerPool(); string[] pos = Enum.GetNames(typeof(PlayerPosition)); cbPosition.ItemsSource = pos; }
public GameManager(GameSettings gameSettings, AsyncProcessor asyncProcessor, LevelManager levelManager, PlayerPool playerPool, SignalBus signalBus) { _asyncProcessor = asyncProcessor; _gameSettings = gameSettings; _levelManager = levelManager; _playerPool = playerPool; _signalBus = signalBus; }
public static Player DetermineWinner(PlayerPool playerPool) { if (playerPool.GetPlayers()[0].GetScore() != playerPool.GetPlayers()[1].GetScore()) { return(playerPool.GetPlayers().OrderByDescending(x => x.GetScore()).First()); } return(null); }
/// <summary> /// 初始化 /// </summary> public static void Init() { playerPool = new PlayerPool(); playerPool.Init(); enemyPool = new EnemyPool(); enemyPool.Init(); genericPropPool = new GenericPropPool(); genericPropPool.Init(); }
private bool PlayerExist(PlayerPool pool, string key) { if (pool.ContainsKey(key)) { return(true); } Debug.LogWarning("PlayerCore null, but received invoke"); return(false); }
public void DanMarinoIsInThePlayerPool() { var pp = new PlayerPool( new RetroRosters( new RosterEventStore())); var result = pp.IsValid(14); Assert.IsTrue(result); }
public static Player DetermineWinner(PlayerPool playerPool, Enums.GameOutcome gameOutcome) { if (playerPool.GetPlayers()[0].GetScore() != playerPool.GetPlayers()[1].GetScore()) { return(playerPool.GetPlayers().OrderByDescending(x => x.GetScore()).First()); } if (gameOutcome == Enums.GameOutcome.NoScoringMaxed) { return(playerPool.GetNextPlayer()); } return(null); }
public void DanMarinoIsAvailableFromThePlayerPool() { var pp = new PlayerPool( new RetroRosters( new RosterEventStore())); var result = pp.GetById(14); Assert.AreEqual( "Dan Marino", result.Name); }
private void Start() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } poolQueue = new Queue <GameObject>(); }
public PlayerManager(Random rand, PlayerPool pool, MapCore mapCore, ObjectPool <ImageBase> imagesDeath, LevelMode levelMode) { this.pool = pool; this.rand = rand; this.mapCore = mapCore; this.imagesDeath = imagesDeath; this.levelMode = levelMode; models = new List <PlayerModelBase>(); models.AddRange(pool.GetCurrentPlayerModels()); pool.AddedPlayer += model => models.Add(model); pool.RemovePlayer += model => models.Remove(model); }
private void Awake() { movement = GetComponent <Movement>(); matching = GetComponent <Matching>(); playerPool = new PlayerPool(prefab); transforms = new TransformAccessArray(4, 2); for (var i = 0; i < 4; i++) { var rent = playerPool.Rent(); var trs = rent.transform; rent.index = i; transforms.Add(trs); } matching .JoinClientAsObservable .Subscribe(index => { Debug.Log(index.ToString()); for (var i = 0; i < transforms.capacity; i++) { var trs = transforms[i]; if (trs.GetComponent <IdentifierComponent>().index != index) { continue; } player = trs; trs.gameObject.AddComponent <PlayerController>(); transforms.RemoveAtSwapBack(i); break; } }); matching .LeaveClientAsObservable .Subscribe(x => { var go = player.gameObject; Destroy(go.GetComponent <PlayerController>()); transforms.Add(player); }); }
private void Awake() { Instance = this; PlayerPool = GetComponent <PlayerPool>(); MatchManager = GetComponent <MatchManager>(); UIManager = GetComponent <UIManager>(); CameraSystem = GetComponent <CameraSystem>(); LevelManager = GetComponent <LevelManager>(); PlayerPool.Init(); MatchManager.Init(); //UIManager.Init(); CameraSystem.Init(); LevelManager.Init(); }
public PlayerPool RequestPoolableBatch(int size) { if (this.HasObjectAvailable(size)) { PlayerPool poolableObjects = new PlayerPool(); poolableObjects = this.RequestPoolable(); return(poolableObjects); } else { Debug.LogError("[GameObjectPool] Insufficient objects available in pool. Count is: " + this.availableObjects.Count + " while requested is " + size + "!"); return(null); } }
public void GameInfoPlayersReceive(JToken jToken) { foreach (var player in jToken.Children <JObject>()) { var playerId = player[ServerParams.UserId].ToString(); if (!PlayerPool.ContainsKey(playerId)) { PlayerManager.CreateServerModel(new PlayerCore(player[ServerParams.UserName].ToString(), playerId, Configs.Player["sample"]), Instantiate(prefabServerPlayer)); } } if (!Camera.IsWatcher && PlayerPool.GetCurrentPlayerModels().Any()) { Camera.Watch(PlayerPool.GetCurrentPlayerModels().First().transform); } }
private void Awake() { single_PT = this; playerPools.Clear(); if (MultiplayerSetting.single_MPS) { maxPlayers = MultiplayerSetting.single_MPS.maxPlayers; for (int i = 0; i < maxPlayers; i++) { Dictionary <string, Queue <GameObject> > tempUnSyncedPoolDict = CreatePoolDictFromPoolList(unSyncedPools); Dictionary <string, Queue <GameObject> > tempSyncedPoolDict = CreatePoolDictFromPoolList(syncedPools); PlayerPool pp = new PlayerPool { unSyncedPoolDictionary = tempUnSyncedPoolDict, syncedPoolDictionary = tempSyncedPoolDict }; playerPools.Add(pp); } } }
public IPlayer[] GetPlayers() { unsafe { CheckIfCallIsValid(); var playerCount = Library.Shared.Core_GetPlayerCount(NativePointer); var pointers = new IntPtr[playerCount]; Library.Shared.Core_GetPlayers(NativePointer, pointers, playerCount); var players = new IPlayer[playerCount]; for (ulong i = 0; i < playerCount; i++) { var playerPointer = pointers[i]; players[i] = PlayerPool.GetOrCreate(this, playerPointer); } return(players); } }
public void Initialization(PlayerCore core, IServerNotify serverNotify, Func <Vector3, string, Vector3?> findClosestPlayer, PlayerPool pool, Func <Vector2> getRandomPosition, Transform imageDeath, LevelMode levelMode, Func <string, PlayerCore> getPlayerById) { this.serverNotify = serverNotify; this.pool = pool; GetRandomPosition = getRandomPosition; GetPlayerById = getPlayerById; if (serverNotify != null) { multiplayer = true; } Core = core; playerAnimation = new PlayerAnimation(GetComponent <Animator>(), imageDeath); this.levelMode = levelMode; weaponActionController.Initilization(findClosestPlayer, ActivateWeapon, core); }
private void AddPlayerPool(Pool pool, bool create) { Player player = db.Players.Include("Pools").Single(item => item.UserName == User.Identity.Name); var playerPool = new PlayerPool() { Id = Guid.NewGuid().ToString(), PoolId = pool.Id, PlayerId = player.Id, IsValid = false }; //make sure this player isn't already in this pool if (player.Pools.SingleOrDefault(item => item.PoolId == pool.Id) == null) { player.Pools.Add(playerPool); playerPool.Games = new List <PlayerPoolGame>(); //if the poolgame game is null, fill them if (pool.Games.First().Game == null) { foreach (PoolGame game in pool.Games) { game.Game = db.Games.Find(game.GameId); } } int confidence = 1; foreach (PoolGame pgame in pool.Games.OrderBy(item => item.Game.GameDateTime, new StringToDateTimeComparer())) { if (create) { db.PoolGames.Add(pgame); } playerPool.Games.Add(new PlayerPoolGame() { PlayerPoolId = playerPool.Id, PoolGameId = pgame.Id, Id = Guid.NewGuid().ToString(), Confidence = confidence, WinnerTeamId = string.Empty, IsValid = true }); confidence++; } //add this pool to the current player db.SaveChanges(); } else { ModelState.AddModelError("", "You are already joined to that pool. Cannot join pool."); } }
public PlayerPool RequestPoolable() { if (this.HasObjectAvailable(1)) { PlayerPool poolableObject = this.availableObjects [this.availableObjects.Count - 1]; poolableObject.SetPoolRef(this); this.availableObjects.RemoveAt(this.availableObjects.Count - 1); this.usedObjects.Add(poolableObject); poolableObject.gameObject.SetActive(true); poolableObject.OnActivate(); return(poolableObject); } else { Debug.LogError("[GameObjectPool] No more poolable object available!"); return(null); } }
public void Initialize() { for (int i = 0; i < this.maxPoolSize; i++) { PlayerPool poolableObject = new PlayerPool(); poolableObject = GameObject.Instantiate <PlayerPool> (this.poolableObjectCopy, this.poolableParent); poolableObject.Initialize(); poolableObject.gameObject.SetActive(false); this.availableObjects.Add(poolableObject); /* * for (int j = 0; j < 3; j++) { * poolableObject[j] = GameObject.Instantiate<APoolable> (this.poolableObjectCopy[j], this.poolableParent[j]); * poolableObject[j].Initialize (); * poolableObject[j].gameObject.SetActive (false); * this.availableObjects.Add (poolableObject[j]); * }*/ } }
// Update is called once per frame void Update() { if (this.fallableObjects.transform.position.y <= Y_THRESHOLD) { this.ResetToOrigin(); } //spawn N objects periodically this.ticks += Time.deltaTime; if (this.ticks >= TIME_DELAY) { this.ticks = 0.0f; //do the spawning PlayerPool poolableObject = this.playerPool.RequestPoolableBatch(this.spawnSize); if (poolableObject == null) { return; } } }
public ISharedEntity GetEntityById(ushort id) { unsafe { CheckIfCallIsValid(); var type = (byte)BaseObjectType.Undefined; var entityPointer = Library.Shared.Core_GetEntityById(NativePointer, id, &type); if (entityPointer == IntPtr.Zero) { return(null); } switch (type) { case (byte)BaseObjectType.Player: return(PlayerPool.Get(entityPointer)); case (byte)BaseObjectType.Vehicle: return(VehiclePool.Get(entityPointer)); default: return(null); } } }
public CameraManager(PlayerPool pool) { _pool = pool; }
//public List<Transform> respawnPosition = new List<Transform>(); private void Awake() { levelManager = FindObjectOfType <LevelManager>(); playerPool = FindObjectOfType <PlayerPool>(); }
public PlayersHub(GamePool gamePool, PlayerPool playerPool, IHubContext <PlayersHub> hubContext) { _gamePool = gamePool; _playerPool = playerPool; _hubContext = hubContext; }
private void Start() { gameController = FindObjectOfType <GameController>(); playerPool = FindObjectOfType <PlayerPool>(); }
protected override void OnStartRunning() { pool = DerbyGameplayBootStrap.PlayerPool; }
public void LogoutReceive(string playerId) { PlayerPool.Remove(playerId); Destroy(PlayerPool[playerId].gameObject); }