private void OnCollisionEnter2D(Collision2D collision) { if (photonView == null) { photonView = GetComponent <PhotonView>(); } if (photonView.IsMine) { if (collision.gameObject.CompareTag("Cart")) { switch (isCarringItem) { case 1: m_goldManager.GetGold(100); isCarringItem = 0; break; case 2: m_goldManager.GetGold(500); isCarringItem = 0; break; } } } }
public void StoreData() { #region storeGeneral // ---- General ---- // if (pGenerator == null) { pGenerator = PathGenerator.instance; } if (pGenerator == null) { Debug.LogError("No PathGenerator found when trying to store data"); } act = pGenerator.floor; if (statistics == null) { statistics = StatisticsEnd.instance; } if (statistics == null) { Debug.LogError("No StatisticsEnd found when trying to store data"); } gameTime = statistics.GetElapsedTime(); if (goldManager == null) { goldManager = GoldManager.instance; } if (goldManager == null) { Debug.LogError("No GoldManager found when trying to store data"); } gold = goldManager.GetGold(); //goldBonus = goldManager.GetGoldBonus(); if (gManager == null) { gManager = GameManager.instance; } if (gManager == null) { Debug.LogError("No GameManager found when trying to store data"); } team = new bool[totalCharacters]; //Set all to false for (int i = 0; i < gManager.teamA.Length; i++) { team[gManager.teamA[i].fUnlockIndex] = true; } if (aManager == null) { aManager = AscensionManager.instance; } if (aManager == null) { Debug.LogError("No AscensionManager found when trying to store data"); } chapter = aManager.currentAscension; if (gBuffs == null) { gBuffs = GlobalBuffs.instance; } if (gBuffs == null) { Debug.LogError("No GlobalBuffs found when trying to store data"); } globalHotDots = gBuffs.GetMatrix(); if (rStorage == null) { rStorage = RelicStorage.instance; } if (rStorage == null) { Debug.LogError("No RelicStorage found when trying to store data"); } relics = new int[rStorage.GetAllRelics().Count]; for (int i = 0; i < rStorage.GetAllRelics().Count; i++) { relics[i] = rStorage.GetAllRelics()[i].IsSelected()? 1: 0; } #endregion #region storeWorld if (pSelector == null) { pSelector = PathSelector.instance; } if (pSelector == null) { Debug.LogError("No PathSelector found when trying to store data"); } playerPos = pSelector.currentWorld.matrixIndex; if (pSelector == null) { pSelector = PathSelector.instance; } if (pSelector == null) { Debug.LogError("No PathSelector found when trying to store data"); } worldTypes = new int[pGenerator.worldMatrix.GetLength(0), pGenerator.worldMatrix.GetLength(1)]; worldWeatherTypes = new int[pGenerator.worldMatrix.GetLength(0), pGenerator.worldMatrix.GetLength(1)]; for (int i = 0; i < pGenerator.worldMatrix.GetLength(0); i++) { for (int j = 0; j < pGenerator.worldMatrix.GetLength(1); j++) { if (pGenerator.worldMatrix[i, j] == null) { worldTypes[i, j] = 0; worldWeatherTypes[i, j] = -1; continue; } worldWeatherTypes[i, j] = pGenerator.worldMatrix[i, j].globalIndex; if (pGenerator.worldMatrix[i, j].worldType == WorldEvent.WorldType.start) { worldTypes[i, j] = 1; continue; } if (pGenerator.worldMatrix[i, j].worldType == WorldEvent.WorldType.normalCombat) { worldTypes[i, j] = 2; continue; } if (pGenerator.worldMatrix[i, j].worldType == WorldEvent.WorldType.shop) { worldTypes[i, j] = 3; continue; } if (pGenerator.worldMatrix[i, j].worldType == WorldEvent.WorldType.blacksmith) { worldTypes[i, j] = 4; continue; } if (pGenerator.worldMatrix[i, j].worldType == WorldEvent.WorldType.boss) { worldTypes[i, j] = 5; continue; } if (pGenerator.worldMatrix[i, j].worldType == WorldEvent.WorldType.elite) { worldTypes[i, j] = 6; continue; } } } //WEATHER TYPES #endregion #region storeCharacters levels = new int[totalCharacters]; //Set all to 0 for (int i = 0; i < gManager.teamA.Length; i++) { levels[gManager.teamA[i].fUnlockIndex] = gManager.teamA[i].GetComponent <FighterExperience>().GetLevel(); } unusedPerks = new int[totalCharacters]; //Set all to 0 for (int i = 0; i < gManager.teamA.Length; i++) { unusedPerks[gManager.teamA[i].fUnlockIndex] = gManager.teamA[i].GetComponent <FighterExperience>().GetPerkPoints(); } stats = new int[totalCharacters, 5]; //Set all to 0 //hp, energy, str, def, spd for (int i = 0; i < gManager.teamA.Length; i++) { stats[gManager.teamA[i].fUnlockIndex, 0] = gManager.teamA[i].hp; stats[gManager.teamA[i].fUnlockIndex, 1] = gManager.teamA[i].energy; stats[gManager.teamA[i].fUnlockIndex, 2] = gManager.teamA[i].str; stats[gManager.teamA[i].fUnlockIndex, 3] = gManager.teamA[i].def; stats[gManager.teamA[i].fUnlockIndex, 4] = gManager.teamA[i].spd; } _stats = new int[totalCharacters, 5]; //Set all to 0 //hp, energy, str, def, spd for (int i = 0; i < gManager.teamA.Length; i++) { _stats[gManager.teamA[i].fUnlockIndex, 0] = gManager.teamA[i]._hp; _stats[gManager.teamA[i].fUnlockIndex, 1] = gManager.teamA[i]._energy; _stats[gManager.teamA[i].fUnlockIndex, 2] = gManager.teamA[i]._str; _stats[gManager.teamA[i].fUnlockIndex, 3] = gManager.teamA[i]._def; _stats[gManager.teamA[i].fUnlockIndex, 4] = gManager.teamA[i]._spd; } experience = new float[totalCharacters]; //Set all to 0 for (int i = 0; i < gManager.teamA.Length; i++) { experience[gManager.teamA[i].fUnlockIndex] = gManager.teamA[i].GetComponent <FighterExperience>().GetCurrentExp(); } talents = new bool[totalCharacters, 7]; //Set all to false for (int i = 0; i < gManager.teamA.Length; i++) { foreach (KeyValuePair <int, PasiveSkill> skills in gManager.teamA[i].GetComponentInChildren <SkillTree>().characterSkillTree) { talents[gManager.teamA[i].fUnlockIndex, skills.Key] = skills.Value.IsSelected(); } } attacks = new int[totalCharacters, 3]; for (int i = 0; i < attacks.GetLength(0); i++) { for (int j = 0; j < attacks.GetLength(1); j++) { attacks[i, j] = -1; } } for (int i = 0; i < gManager.teamA.Length; i++) { for (int j = 0; j < gManager.teamA[i].attacks.Length; j++) { attacks[gManager.teamA[i].fUnlockIndex, j] = gManager.teamA[i].attacks[j] == null ? -1 : gManager.teamA[i].attacks[j].GetAttack().generalIndex; attackLevels[gManager.teamA[i].fUnlockIndex, j] = gManager.teamA[i].attacks[j] == null ? -1 : gManager.teamA[i].attacks[j].level; } } #endregion }