private void HashCheck(int sourcePlayerID) { HashProjection hasher = new HashProjection(ES); ES.ApplyProjection(hasher, EventStream.AllExistingEvents); View.RPC("HashCheckReturn", PhotonHelper.GetPlayerByID(sourcePlayerID), PhotonNetwork.player.ID, hasher.GenerateHashCode(), ES.EventCount); }
IEnumerator loadCharCoroutine(GameObject map) { yield return(new WaitForSeconds(1.5f)); var proxyData = FindObjectOfType <GameDataProxy> (); MapData mapData = Resources.Load <MapData> (m_mapDataName); for (var team = 0; team < mapData.heroesStartData.Length; ++team) { foreach (var startPosition in mapData.heroesStartData[team].positions) { if (!proxyData.isBotGame && proxyData.team != team) { continue; } var hero = PhotonHelper.Instantiate(m_heroPrefab, startPosition, Quaternion.identity, 0); var heroType = (proxyData.team == team) ? proxyData.heroType : getRandomHeroType(); hero.GetComponent <Hero>().initialize(startPosition, team, heroType, proxyData.isBotGame && proxyData.team == team); } } if (PhotonHelper.isMaster()) { foreach (var creepData in mapData.mapCreepData) { var creep = PhotonHelper.Instantiate(m_creepPrefab, map.transform.position, Quaternion.identity, 0); creep.GetComponent <Creep>().initialize(creepData); } } }
public void RoundStartFun(int unitId) { Debug.Log("RPC_RoundStart"); TimeFrozen = false; _roundStart = Time.time; var foundUnit = ApplicationModel.MatchModel.Units.First(u => u.Id == unitId); if (!PhotonHelper.PlayerIsSinglePlayer()) { MatchController.SetCurrentUnit(foundUnit); } if (foundUnit.Color == GetCurrentPlayerColor() && GetCurrentPlayer().Name == PhotonNetwork.NickName) { foundUnit.SetAllowControll(true); foundUnit.SetScopeVisibility(true); } else { foundUnit.SetAllowControll(false); foundUnit.SetScopeVisibility(false); } CameraService.SetCameraFollowAndRotationTarget(foundUnit.gameObject.transform); CurrentWeaponController.ResetPower(); CurrentWeaponController.SetCurrentWeapon(ShootService.GetNoneWeapon()); if (RoundChangedEvent != null) { RoundChangedEvent.Invoke(this, new EventArgs()); } EndMatchIfNeeded(); }
public void RequestHashCheck(Action finished) { if (ReturnHashes != null) { throw new Exception("Already attempting to compare game hashes"); } PhotonHelper.RequestFromPlayers( Request, r => ReturnHashes = r, xs => { HashSet <int> hashes = new HashSet <int>(); for (int i = 0; i < xs.Count; i++) { Assert.IsTrue(xs[i].HasValue); hashes.Add(xs[i].Value); } if (hashes.Count != 1) { throw new Exception("Hash check failed, there were " + hashes.Count + " different hashes"); } ReturnHashes = null; finished.Invoke(); }, PhotonNetwork.player.ID ); }
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) { try { if (source != null && !source.ToString().IsNullOrWhiteSpace() && source.ToString() != "{}") { var value = JsonConvert.DeserializeObject <PhotonValue>(source.ToString()); if (value.Tags != null && value.Tags.Count > 0) { // Get the meta data doc type var metaDataDocTypeAlias = PhotonHelper.GetMetaDataDocType(propertyType.DataTypeId); var metaDataDocType = PublishedContentType.Get(PublishedItemType.Content, metaDataDocTypeAlias); // Loop tags and covert meta data foreach (var tag in value.Tags) { tag.MetaData = ConvertDataToSource_DocType(propertyType, metaDataDocType, tag.RawMetaData, preview); } } return(value); } } catch (Exception e) { LogHelper.Error <PhotonValueConverter>("Error converting value", e); } return(null); }
private void CheckIfShouldEndRound() { if (PhotonHelper.PlayerIsMultiplayerHost() || PhotonHelper.PlayerIsSinglePlayer()) { if (ShouldRoundEnd(GameObjectsProviderService.CurrentWeaponController.GetCurrentWeapon())) { GameObjectsProviderService.MainPhotonView.RPC("RPC_SetTimeTo3Sec", RpcTarget.Others); GameObjectsProviderService.MainGameController.SetTimeTo3Sec(); } } }
public void RequestES(Action <byte[]> finished) { if (ReturnedESData != null) { throw new Exception("Already attempting to get event source data"); } ReturnedESData = bx => finished.Invoke(bx); View.RPC("RequestESData", PhotonHelper.SelectRandomPlayer(), PhotonNetwork.player.ID); }
// Use this for initialization void Awake() { if (PhotonHelper.PlayerIsMultiplayerGuest()) { ApplicationModel.LoadFromServer(); } CurrentWeaponController = new CurrentWeaponController(ApplicationModel.CurrentWeaponModel); MatchController = new MatchController(ApplicationModel.MatchModel, ApplicationModel.PlayersToCreate); _roundLength = 45; }
public void CreateUnit(Vector3 position, Player player) { if (PhotonHelper.PlayerIsMultiplayerHost()) { int id = UniqueIdHelper.GetNext(); GameObjectsProviderService.MainPhotonView.RPC("RPC_CreateUnit", RpcTarget.All, position, player.Name, id); } else if (PhotonNetwork.OfflineMode) { UnitCreatorService.CreateSinglePlayerUnit(position, player); } }
public virtual void moveTo(Vector3 position) { if (!PhotonHelper.isMine(this)) { return; } transform.DOKill(); position.y = GetComponent <Rigidbody>().position.y; GetComponent <Rigidbody>().MoveRotation(Quaternion.LookRotation(transform.position - position)); GetComponent <Rigidbody>().DOMove(position, m_data.moveSpeed).SetSpeedBased(); }
void Update() { if (!PhotonHelper.isMine(this)) { return; } // if (photonView != null && !photonView.isMine) var canAttack = updateAttackTime(); if (canAttack && m_attackTarget != null && !m_isDead) { attack(m_attackTarget); m_shouldSendAttack = true; } }
public void EndMatchIfNeeded() { if (PhotonHelper.PlayerIsMultiplayerHost() || PhotonNetwork.OfflineMode) { if (MatchController.HasPlayersQueueOnlyOneTeam()) { GameOver = true; MatchController.DequeuePlayer(); SceneManager.LoadScene(SceneNames.GameOverScene); } else if (MatchController.IsPlayersQueueEmpty()) { GameOver = true; SceneManager.LoadScene(SceneNames.GameOverScene); } } }
public void SendEntityModAndConfirm(IEntityModifier m, Action finished) { int requestID = NetworkInteractionTracker.RecordMassPingRequestStarted(); PhotonHelper.RequestFromPlayers( DependentRequest, r => ReturnModSentByRequestID.Add(requestID, r), _ => { Debug.Log("Mod sent to all players, should be done locally too"); ReturnModSentByRequestID.Remove(requestID); if (finished != null) { finished.Invoke(); } }, PhotonNetwork.player.ID, m, requestID ); }
private IEnumerator RoundCoroutine() { yield return(new WaitForSeconds(2)); if (PhotonHelper.PlayerIsMultiplayerGuest()) { } else if (PhotonHelper.PlayerIsMultiplayerHost()) { MatchController.DequeuePlayer(); var unit = MatchController.GetCurrenUnit(); GameObjectsProviderService.MainPhotonView.RPC("RPC_RoundStart", RpcTarget.All, unit.Id); } else { RoundStart(); } }
public bool takeDamage(Character target, float amount) { var damage = Mathf.Max(amount - m_data.defence, 1.0f); m_health = Mathf.Max(0.0f, m_health - damage); if (OnHealthChanged != null) { OnHealthChanged(m_health / m_data.maxHealth); } if (m_health <= 0.01f && PhotonHelper.isMine(this)) { whenHpZero(); m_shouldDestroy = true; return(true); } return(false); }
public void SendIndependentModAndConfirm(IIndependentModifier m, Action finished) { int requestID = NetworkInteractionTracker.RecordMassPingRequestStarted(); Action <int, bool> ret = null; ReturnModSentByRequestID[requestID] = ret; long targetStep = IntervalTimer.NextPossibleStepToTarget(NetworkInteractionTracker.MaxPing); PhotonHelper.RequestFromPlayers( IndependentRequest, r => ReturnModSentByRequestID.Add(requestID, r), _ => { ReturnModSentByRequestID.Remove(requestID); if (finished != null) { finished.Invoke(); } }, PhotonNetwork.player.ID, m, requestID, targetStep ); }
public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) { var oldValue = new PhotonValue(); var newValue = new PhotonValue(); // Get the old src path if (currentValue != null && !string.IsNullOrEmpty(currentValue.ToString())) { oldValue = PhotonValue.Parse(currentValue.ToString()); } //get the new src path if (editorValue.Value != null) { newValue = PhotonValue.Parse(editorValue.Value.ToString()); } //handle storing / deleteing the media items ConvertDbToEditor_HandleMedia(editorValue, oldValue, newValue); // Loop tags and covert meta data if (newValue != null && newValue.Tags != null && newValue.Tags.Count > 0) { // Get the meta data doc type var metaDataDocTypeAlias = PhotonHelper.GetMetaDataDocType(editorValue.PreValues); var metaDataDocType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(metaDataDocTypeAlias); foreach (var tag in newValue.Tags) { tag.RawMetaData = ConvertEditorToDb_DocType(metaDataDocType, tag.RawMetaData); } } // Return json return(JsonConvert.SerializeObject(newValue)); }
public override object ConvertDbToEditor(Property property, PropertyType propertyType, IDataTypeService dataTypeService) { // Make sure we have a value if (property.Value == null || string.IsNullOrWhiteSpace(property.Value.ToString())) { return(string.Empty); } // Parse to photon value for ease var value = JsonConvert.DeserializeObject <PhotonValue>(property.Value.ToString()); if (value == null) { return(string.Empty); } // Loop tags and covert meta data if (value.Tags != null && value.Tags.Count > 0) { // Get the meta data doc type var metaDataDocTypeAlias = PhotonHelper.GetMetaDataDocType(propertyType.DataTypeDefinitionId); var metaDataDocType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(metaDataDocTypeAlias); foreach (var tag in value.Tags) { tag.RawMetaData = ConvertDbToEditor_DocType(metaDataDocType, tag.RawMetaData); } } // We serialize back down as we want the editor to handle // the data as a generic object type, not our specific classes property.Value = JsonConvert.SerializeObject(value); return(base.ConvertDbToEditor(property, propertyType, dataTypeService)); }
public override string ConvertDbToString(Property property, PropertyType propertyType, IDataTypeService dataTypeService) { // Make sure we have a value if (property.Value == null || string.IsNullOrWhiteSpace(property.Value.ToString())) { return(string.Empty); } // Parse to photon value for ease var value = JsonConvert.DeserializeObject <PhotonValue>(property.Value.ToString()); if (value == null) { return(string.Empty); } // Loop tags and covert meta data if (value.Tags != null && value.Tags.Count > 0) { // Get the meta data doc type var metaDataDocTypeAlias = PhotonHelper.GetMetaDataDocType(propertyType.DataTypeDefinitionId); var metaDataDocType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(metaDataDocTypeAlias); foreach (var tag in value.Tags) { tag.RawMetaData = ConvertDbToString_DocType(metaDataDocType, tag.RawMetaData); } } // Update the value on the property property.Value = JsonConvert.SerializeObject(value); // Pass the call down return(base.ConvertDbToString(property, propertyType, dataTypeService)); }
private void RequestIndividualPlayerPing(int PhotonPlayerID) { int requestID = NetworkInteractionTracker.RecordPingRequestStartedForPlayer(PhotonPlayerID); View.RPC("ReceivePingRequest", PhotonHelper.GetPlayerByID(PhotonPlayerID), PhotonNetwork.player.ID, requestID); }
private void RequestESData(int sourcePlayerID) { ES.ExtractByteData(bx => View.RPC("AcceptESData", PhotonHelper.GetPlayerByID(sourcePlayerID), bx)); }
protected virtual void onDeathAnimation() { PhotonHelper.Destroy(gameObject); }