void SpawnPortal(SignalData portalSpawnData) { Vector3 position = portalSpawnData.get <Vector3>("SpawnPosition"); Vector3 direction = portalSpawnData.get <Vector3>("SpawnDirection"); PortalColorData portalColor = portalSpawnData.get <PortalColorData>("PortalColors"); int arenaId = portalSpawnData.get <int>("ArenaId"); Debug.Log(arenaId); var spawnPosition = new Vector3(position.x, 1.4f, position.z) + direction * 0.01f; Quaternion portalRotation = Quaternion.LookRotation(direction); GameObject portalObject = Instantiate(portalPrefab, spawnPosition, portalRotation); GameObject correspondingPortal = null; if (PortalMap.ContainsKey(portalColor)) { if (PortalMap[portalColor].ContainsKey(arenaId)) { Destroy(PortalMap[portalColor][arenaId]); PortalMap[portalColor].Remove(arenaId); } correspondingPortal = getCorrespondingPortal(arenaId, portalColor); } else { PortalMap.Add(portalColor, new Dictionary <int, GameObject>()); } if (correspondingPortal != null) { correspondingPortal.GetComponent <Portal>().changeCorrespondingPortal(portalObject); } portalObject.GetComponent <Portal>().initialize(portalColor, correspondingPortal, arenaId); PortalMap[portalColor].Add(arenaId, portalObject); }
void onPortalFluidUse(SignalData fluidUSedData) { var arenaId = fluidUSedData.get <int>("arenaId"); var position = fluidUSedData.get <Vector3>("location"); var currentFluidColor = ArenaPointColorMap[arenaId][position]; ArenaPointColorMap[arenaId].Remove(position); StartCoroutine(RespawnConsumedFluid(arenaId, position, currentFluidColor)); }
void onPortalTimeOut(SignalData data) { int arenaId = data.get <int>("ArenaId"); PortalColorData portalColor = data.get <PortalColorData>("PortalColors"); GameObject otherPortal = getCorrespondingPortal(arenaId, portalColor); if (otherPortal != null) { otherPortal.GetComponent <Portal>().changeCorrespondingPortal(null); } PortalMap[portalColor].Remove(arenaId); Debug.Log("Portal map"); }
void spawnBullet(SignalData data) { Transform launchPoint = data.get <Transform>("launchPoint"); int playerHashCode = data.get <int>("playerHashCode"); int arenaId = data.get <int>("arenaId"); int bulletType = (int)data.get <BulletTypes>("bulletType"); if (!PlayerBulletCount.ContainsKey(playerHashCode)) { PlayerBulletCount.Add(playerHashCode, 0); } if (PlayerBulletCount[playerHashCode] < MaxBulletsPerPerson) { GameObject bullet = Instantiate(BulletPrefabs[bulletType], launchPoint.position, Quaternion.identity); Bullet bulletScript = bullet.GetComponent <Bullet>(); bulletScript.initialize(launchPoint.position, launchPoint.forward, arenaId, playerHashCode); PlayerBulletCount[playerHashCode]++; } }
void removeBulletFromPool(SignalData data) { Bullet bullet = data.get <Bullet>("Bullet"); PlayerBulletCount[bullet.PlayerHashCode]--; }