public void GetAllPlayerUnitData() { if (IsMultiPlayer) { ExitGames.Client.Photon.Hashtable hs = new ExitGames.Client.Photon.Hashtable(); hs = PhotonNetwork.room.CustomProperties; if (hs.ContainsKey("Players")) { PF_GamePlay.AllSavedCharacterUnitData = new Dictionary <string, FG_SavedCharacter>(); string[] playerNames = (string[])hs["Players"]; for (int i = 0; i < playerNames.Length; i++) { PhotonPlayer player = PhotonNetwork.playerList.ToList().Find(x => x.UserId.Contains(playerNames[i])); FG_SavedCharacter saved = PlayFab.Json.PlayFabSimpleJson.DeserializeObject <FG_SavedCharacter>((string)player.CustomProperties["SavedData"]); PF_GamePlay.AllSavedCharacterUnitData.Add(playerNames[i], saved); } } else { Debug.Log("room prperties do not contain the key player"); } } else { } }
void SetSavedTeamData() { if (PF_PlayerData.MyTeamsCharacterId == null || PF_PlayerData.MyTeamsCharacterId.Count == 0) { return; } PF_PlayerData.SavedTeam = new List <FG_SavedCharacter>(); PF_GamePlay.AllSavedCharacterUnitData = new Dictionary <string, FG_SavedCharacter>(); int count = 1; foreach (var id in PF_PlayerData.MyTeamsCharacterId["CurrentTeam"]) { CharacterResult cha = PF_PlayerData.playerCharacters.Find(x => x.CharacterId.Contains(id)); FG_SavedCharacter saved = new FG_SavedCharacter() { characterDetails = cha, baseClass = PF_GameData.Classes[cha.CharacterType], characterData = PF_PlayerData.playerCharacterData[id] }; PF_PlayerData.SavedTeam.Add(saved); PF_GamePlay.AllSavedCharacterUnitData.Add(saved.baseClass.CatalogCode + "_" + count, saved); count++; } }
//public bool isPlayer = false; public void Init(FG_SavedCharacter saved, CharacterUnitController controller) { unitController = controller; map = controller.map; tileX = (int)transform.position.x; tileY = (int)transform.position.y; savedCharacter = saved; savedCharacter.SetMaxVitals(); savedCharacter.RefillVitals(); GetComponent <SpriteRenderer>().sprite = GameController.Instance.iconManager.GetIconById(savedCharacter.baseClass.Icon); //add spells AddSpell(saved.characterData.Spell1); AddSpell(saved.characterData.Spell2); AddSpell(saved.characterData.Spell3); AddSpell(saved.characterData.Spell4); // if (gameObject.tag == "Player") { isPlayerMark.SetActive(true); isEnemyMark.SetActive(false); } else { isPlayerMark.SetActive(false); isEnemyMark.SetActive(true); } gameObject.SetActive(true); InitState(); }
public override void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps) { var hash = new ExitGames.Client.Photon.Hashtable(); hash = (ExitGames.Client.Photon.Hashtable)playerAndUpdatedProps[1]; FG_SavedCharacter cha = PlayFab.Json.PlayFabSimpleJson.DeserializeObject <FG_SavedCharacter>((string)hash["SavedData"]); DialogCanvasController.Instance.CloseLoadingPrompt(PlayFabAPIMethods.Generic); }
public void Init() { //Set up Enemy Data List <string> encounters = PF_GamePlay.ActiveQuest.Acts.Values.ToList()[0].Encounters.SpawnSpecificEncountersByID; List <List <int> > positions = PF_GamePlay.ActiveQuest.Acts.Values.ToList()[0].Encounters.EncounterSpawnPosition; for (int i = 0; i < encounters.Count; i++) { Unit unit = Instantiate(unitPre, Vector3.zero, Quaternion.identity); unit.tag = "Enemy"; unit.name = "Enemy_" + encounters[i] + "_" + i; unit.transform.position = new Vector2(positions[i][0], positions[i][1]); FG_ClassDetail detail = PF_GameData.Classes[encounters[i]]; FG_SavedCharacter saved = new FG_SavedCharacter() { baseClass = detail, characterData = new FG_CharacterData() { Spell1 = detail.Spell1, Spell2 = detail.Spell2, Spell3 = detail.Spell3, Spell4 = detail.Spell4, CharacterLevel = PF_GamePlay.ActiveQuest.Acts.Values.ToList()[0].Encounters.EncountersLevel[i] } }; allCharacterUnit.Add(unit); AllEnemyUnit.Add(unit); allCharacterDictionary.Add(unit.name, unit); unit.Init(saved, this); map.OnUnitMoving(unit.tileX, unit.tileY, unit.tileX, unit.tileY); } ///Set Up Player Data List <List <int> > playerPositions = PF_GamePlay.ActiveQuest.Acts.Values.ToList()[0].PlayerSpawnPosition; for (int i = 0; i < PF_GamePlay.AllSavedCharacterUnitData.Count; i++) { Unit unit = Instantiate(unitPre);//, new Vector2(4 + i, 4 + i), Quaternion.identity); unit.transform.position = new Vector2(playerPositions[i][0], playerPositions[i][1]); unit.tag = "Player"; unit.name = PF_GamePlay.AllSavedCharacterUnitData.Keys.ToList()[i]; FG_SavedCharacter saved = PF_GamePlay.AllSavedCharacterUnitData[unit.name]; allCharacterUnit.Add(unit); allPlayerUnit.Add(unit); allCharacterDictionary.Add(unit.name, unit); unit.gameObject.SetActive(true); unit.Init(saved, this); map.OnUnitMoving(unit.tileX, unit.tileY, unit.tileX, unit.tileY); } allCharacterUnit.Sort(); }
/// <summary> /// write back the quest progress to playfab /// </summary> public static void SavePlayerData(FG_SavedCharacter savedCha, QuestTracker questProgress) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.SavePlayerInfo); ExecuteCloudScriptRequest request = new ExecuteCloudScriptRequest(); request.FunctionName = "SaveProgress"; request.FunctionParameter = new { CurrentPlayerData = savedCha, LevelRamp = PF_GameData.CharacterLevelRamp, QuestProgress = questProgress }; PlayFabClientAPI.ExecuteCloudScript(request, OnSavePlayerDataSuccess, PF_Bridge.PlayFabErrorCallback); }
public void SetButton(FG_CharacterData data, CharacterResult cha, Sprite sprite) { icon.sprite = sprite; myBtn.GetComponentInChildren <Text>().text = data.ClassDetails.CatalogCode; //Fill slot if (PF_GameData.Classes.ContainsKey(cha.CharacterType)) { saved = (new FG_SavedCharacter() { baseClass = PF_GameData.Classes[cha.CharacterType], characterDetails = cha, characterData = PF_PlayerData.playerCharacterData.ContainsKey(cha.CharacterId) ? PF_PlayerData.playerCharacterData[cha.CharacterId] : null }); } }
public int DmgCalculator(FG_SavedCharacter Attacker, FG_SavedCharacter target, FG_Spell spell) { int dmg = 0; int spellPower = spell.Dmg; int AtkPoint = Attacker.PlayerVitals.Attack; int DefPoint = target.PlayerVitals.Defense; if (spellPower <= 0) { return(0); } else { dmg = (int)(0.5f * (float)spellPower * (float)AtkPoint / (float)DefPoint) + 1; } Debug.Log(spellPower + "|" + AtkPoint + "|" + DefPoint + "|" + dmg); return(dmg); }