public override bool Deliver(LogicLevel level) { LogicAvatar avatar = level.GetHomeOwnerAvatar(); int count = avatar.GetResourceCount(this.m_resourceData) + this.m_resourceAmount; avatar.SetResourceCount(this.m_resourceData, count); avatar.GetChangeListener().CommodityCountChanged(0, this.m_resourceData, count); return(true); }
/// <summary> /// Loads the npc attack state. /// </summary> public void LoadNpcAttackState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { if (this._state == 1) { Debugger.Error("loadAttackState called from invalid state"); } else { this._state = 2; this._currentTimestamp = currentTimestamp; this._calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } if (homeOwnerAvatar.IsNpcAvatar()) { LogicNpcAvatar npcAvatar = (LogicNpcAvatar)homeOwnerAvatar; LogicNpcData npcData = npcAvatar.GetNpcData(); homeOwnerAvatar.SetResourceCount(LogicDataTables.GetGoldData(), LogicMath.Max(npcData.Gold - visitorAvatar.GetLootedNpcGold(npcData), 0)); homeOwnerAvatar.SetResourceCount(LogicDataTables.GetElixirData(), LogicMath.Max(npcData.Elixir - visitorAvatar.GetLootedNpcElixir(npcData), 0)); this._level.SetMatchType(2, 0); this._level.SetHome(home, false); this._level.SetHomeOwnerAvatar(homeOwnerAvatar); this._level.SetVisitorAvatar(visitorAvatar); this._level.FastForwardTime(secondsSinceLastSave); this._level.LoadingFinished(); } else { Debugger.Error("loadNpcAttackState called and home owner is not npc avatar"); } } }