public void RunTick(PlayerTickData tickData = null) { if (tickData != null) { if (tickData.dataType == (int)TickDataType.SpawnPlayer) { SpawnPlayerTickData spawnData = tickData.data as SpawnPlayerTickData; CharacterInfo charInfo = new CharacterInfo((ClassType)spawnData.playerClass, (Weapon)spawnData.weapon, Boots.Armor); spawnPlayer(charInfo); } else if (tickData.dataType == (int)TickDataType.SpawnEnemy) { if (TickManager.Instance.Tick % 50 == 0) { SpawnEnemyTickData spawnData = tickData.data as SpawnEnemyTickData; Vector3 position = new Vector3(spawnData.xPos, spawnData.yPos, spawnData.zPos); } } else if (tickData.dataType == (int)TickDataType.HealthPack) { HealthPackData hpData = tickData.data as HealthPackData; dropItem(new Vector3(hpData.xPos, hpData.yPos, 0)); } } }
public IEnumerator DropItem() { yield return(new WaitForSeconds(3)); Debug.Log(TickManager.Instance.Tick); Random.InitState(TickManager.Instance.Tick); int dropNum = Random.Range(0, dropNumber); if (dropNum == 1) { PlayerTickData itemData = new PlayerTickData(); itemData.peerId = 10000; itemData.dataType = (int)TickDataType.HealthPack; HealthPackData hpData = new HealthPackData(); hpData.xPos = transform.position.x; hpData.yPos = transform.position.y; itemData.data = hpData; byte[] byteData = ObjectToByteArray <PlayerTickData>(itemData); tickList.Add(byteData); TickManager.Instance.ReceiveTick(byteData); Debug.Log("you get an item"); } else { Debug.Log("no item for you"); } Destroy(gameObject); }