public override void DoAction() { base.DoAction(); currentChest = this.GetComponent <ChestInstance>(); // Ganha itens do chest se tiver uma chave if (PlayerInstance.Instance.Keys > 0) { PlayerInstance.Instance.IncreaseMoney(currentChest.Coin); PlayerInstance.Instance.IncreaseHealth(currentChest.HealValue); ExperienceManager.Instance.IncreaseXPPoints(currentChest.XP); if (currentChest.Coin > 0) { Debug.Log("Dinheiro: " + currentChest.Coin); } if (currentChest.HealValue > 0) { Debug.Log("Vida: " + currentChest.HealValue); } if (currentChest.XP > 0) { Debug.Log("XP: " + currentChest.XP); } // randomiza quais dos feiticos possiveis podem sair if (currentChest.Feiticos.Count > 0) { int typeIndex = Random.Range(0, currentChest.Feiticos.Count); // cria o feitico GameObject Spell = SpellManager.Instance.CreateSpell(currentChest.Feiticos[typeIndex]); if (Spell != null) { Debug.Log("Feitiços: " + currentChest.Feiticos[typeIndex]); } else { Debug.Log("Limite de feitiços atingido"); } // Adiciona o feitico a lista de feiticos } //Tocar animação do bau abrindo gameObject.transform.GetChild(0).GetChild(1).GetComponent <Animator>().Play("Bau-Open"); PlayerInstance.Instance.Keys -= 1; ExperienceManager.Instance.UpdateUI(); } }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); /*int version = */ reader.ReadEncodedInt(); m_Artifacts = new ChestInstance[m_Entries.Length]; m_Table = new Hashtable( m_Entries.Length ); int length = reader.ReadEncodedInt(); for ( int i = 0; i < length; i++ ) { Item item = reader.ReadItem(); DateTime nextRespawn = reader.ReadDeltaTime(); if ( i < m_Artifacts.Length ) { ChestInstance ci = new ChestInstance( m_Entries[i], item, nextRespawn ); m_Artifacts[i] = ci; if ( ci.Item != null ) m_Table[ci.Item] = ci; } } for ( int i = length; i < m_Entries.Length; i++ ) m_Artifacts[i] = new ChestInstance( m_Entries[i] ); m_RespawnTimer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromMinutes( 7.0 ), new TimerCallback( CheckRespawn ) ); }
private DungeonChestsSpawner() : base(1) { Name = "Dungeon Treasure Chests Spawner - Internal"; Movable = false; m_Artifacts = new ChestInstance[m_Entries.Length]; m_Table = new Hashtable( m_Entries.Length ); for ( int i = 0; i < m_Entries.Length; i++ ) m_Artifacts[i] = new ChestInstance( m_Entries[i] ); m_RespawnTimer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromMinutes( 7.0 ), new TimerCallback( CheckRespawn ) ); }