private void SerializeActionStart(Network.HistActionStart a, BinaryWriter w) { w.Write(a.Index); w.Write(a.Entity); w.Write(a.Target); w.Write((int)a.BlockType); }
private Spell DetermineTriggerSpell(Card card) { if (card == null) { return(null); } Network.HistActionStart sourceAction = base.m_taskList.GetSourceAction(); return(card.GetTriggerSpell(sourceAction.Index, true)); }
public bool HasTargetEntity() { Network.HistActionStart sourceAction = this.GetSourceAction(); if (sourceAction == null) { return(false); } int target = sourceAction.Target; return(GameState.Get().GetEntity(target) != null); }
private string FindRevealedCardId(PowerTaskList taskList) { Network.HistActionStart sourceAction = taskList.GetSourceAction(); List <PowerTask> list = taskList.GetTaskList(); for (int i = 0; i < list.Count; i++) { PowerTask task = list[i]; Network.HistShowEntity power = task.GetPower() as Network.HistShowEntity; if ((power != null) && (power.Entity.ID == sourceAction.Entity)) { return(power.Entity.CardID); } } return(null); }
public Entity GetTargetEntity() { Network.HistActionStart sourceAction = this.GetSourceAction(); if (sourceAction == null) { return(null); } int target = sourceAction.Target; Entity entity = GameState.Get().GetEntity(target); if (entity == null) { UnityEngine.Debug.LogWarning(string.Format("PowerProcessor.GetSourceEntity() - task list {0} has a target entity with id {1} but there is no entity with that id", this.m_id, target)); return(null); } return(entity); }
protected bool AddSinglePowerTarget_FromSourceAction(Network.HistActionStart sourceAction) { Entity entity = GameState.Get().GetEntity(sourceAction.Target); if (entity == null) { return(false); } Card card = entity.GetCard(); if (card == null) { Log.Power.Print(string.Format("{0}.AddSinglePowerTarget_FromSourceAction() - FAILED Target {1} in sourceAction has no Card", this, sourceAction.Target), new object[0]); return(false); } this.AddTarget(card.gameObject); return(true); }
protected bool AddSinglePowerTarget() { Card sourceCard = this.GetSourceCard(); if (sourceCard == null) { object[] args = new object[] { this }; Log.Power.PrintWarning("{0}.AddSinglePowerTarget() - a source card was never added", args); return(false); } Network.HistActionStart sourceAction = this.m_taskList.GetSourceAction(); if (sourceAction == null) { object[] objArray2 = new object[] { this }; Log.Power.PrintError("{0}.AddSinglePowerTarget() - got a task list with no source action", objArray2); return(false); } List <PowerTask> taskList = this.m_taskList.GetTaskList(); return(this.AddSinglePowerTarget_FromSourceAction(sourceAction) || (this.AddSinglePowerTarget_FromMetaData(taskList) || this.AddSinglePowerTarget_FromAnyPower(sourceCard, taskList))); }
private void StartCurrentTaskList() { GameState state = GameState.Get(); Network.HistActionStart sourceAction = this.m_currentTaskList.GetSourceAction(); if (sourceAction == null) { this.DoCurrentTaskList(); } else { int id = sourceAction.Entity; Entity sourceEntity = state.GetEntity(id); if (sourceEntity == null) { Debug.LogError(string.Format("PowerProcessor.StartCurrentTaskList() - WARNING got a power with a null source entity (ID={0})", id)); this.DoCurrentTaskList(); } else if (!this.DoTaskListWithSpellController(state, this.m_currentTaskList, sourceEntity)) { this.DoCurrentTaskList(); } } }
private void NotifyWillProcessTaskList(PowerTaskList taskList) { if (ThinkEmoteManager.Get() != null) { ThinkEmoteManager.Get().NotifyOfActivity(); } if (taskList.IsSourceActionOrigin()) { Network.HistActionStart sourceAction = taskList.GetSourceAction(); if (sourceAction.BlockType == HistoryBlock.Type.PLAY) { Entity entity = GameState.Get().GetEntity(sourceAction.Entity); if (entity.GetController().IsOpposingSide()) { string cardId = entity.GetCardId(); if (string.IsNullOrEmpty(cardId)) { cardId = this.FindRevealedCardId(taskList); } GameState.Get().GetGameEntity().NotifyOfOpponentWillPlayCard(cardId); } } } }
public void SetSourceAction(Network.HistActionStart startAction) { object[] objArray1 = new object[] { startAction }; base.method_8("SetSourceAction", objArray1); }
public void SetSourceAction(Network.HistActionStart startAction) { this.m_sourceAction = startAction; }
public bool AddSinglePowerTarget_FromSourceAction(Network.HistActionStart sourceAction) { object[] objArray1 = new object[] { sourceAction }; return(base.method_11 <bool>("AddSinglePowerTarget_FromSourceAction", objArray1)); }
private void PrepareHistoryForCurrentTaskList() { object[] args = new object[] { this.m_currentTaskList.GetId() }; Log.Power.Print("PowerProcessor.PrepareHistoryForCurrentTaskList() - m_currentTaskList={0}", args); Network.HistActionStart sourceAction = this.m_currentTaskList.GetSourceAction(); if (sourceAction != null) { if (sourceAction.BlockType != HistoryBlock.Type.ATTACK) { if (sourceAction.BlockType == HistoryBlock.Type.PLAY) { Entity playedEntity = GameState.Get().GetEntity(sourceAction.Entity); if (playedEntity != null) { if (this.m_currentTaskList.IsSourceActionOrigin()) { Entity targetedEntity = GameState.Get().GetEntity(sourceAction.Target); HistoryManager.Get().CreateCardPlayedTile(playedEntity, targetedEntity); this.m_currentTaskList.SetSpawnedHistoryTile(true); if (playedEntity.IsControlledByFriendlySidePlayer()) { GameState.Get().GetGameEntity().NotifyOfFriendlyPlayedCard(playedEntity); } if (this.ShouldShowPlayedBigCard(playedEntity)) { if (playedEntity.IsControlledByOpposingSidePlayer()) { GameState.Get().GetGameEntity().NotifyOfOpponentPlayedCard(playedEntity); } bool wasCountered = this.m_currentTaskList.WasThePlayedSpellCountered(playedEntity); this.m_historyBlocking = true; this.m_historyBlockingTaskList = this.m_currentTaskList; HistoryManager.Get().CreatePlayedBigCard(playedEntity, new HistoryManager.FinishedCallback(this.OnBigCardFinished), wasCountered); } } this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } } else if (sourceAction.BlockType == HistoryBlock.Type.POWER) { this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } else if (sourceAction.BlockType == HistoryBlock.Type.JOUST) { this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } else if (sourceAction.BlockType == HistoryBlock.Type.TRIGGER) { Entity triggeredEntity = GameState.Get().GetEntity(sourceAction.Entity); if (triggeredEntity != null) { if (triggeredEntity.IsSecret()) { if (this.m_currentTaskList.IsSourceActionOrigin()) { HistoryManager.Get().CreateTriggerTile(triggeredEntity); this.m_currentTaskList.SetSpawnedHistoryTile(true); this.m_historyBlocking = true; this.m_historyBlockingTaskList = this.m_currentTaskList; HistoryManager.Get().CreateSecretBigCard(triggeredEntity, new HistoryManager.FinishedCallback(this.OnBigCardFinished)); } this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } else { if (this.m_currentTaskList.IsSourceActionOrigin()) { PowerHistoryInfo powerHistoryInfo = triggeredEntity.GetPowerHistoryInfo(sourceAction.Index); if ((powerHistoryInfo != null) && powerHistoryInfo.ShouldShowInHistory()) { if (triggeredEntity.HasTag(GAME_TAG.HISTORY_PROXY)) { Entity entity6 = GameState.Get().GetEntity(triggeredEntity.GetTag(GAME_TAG.HISTORY_PROXY)); HistoryManager.Get().CreateCardPlayedTile(entity6, null); if ((triggeredEntity.GetController() != GameState.Get().GetFriendlySidePlayer()) || !triggeredEntity.HasTag(GAME_TAG.HISTORY_PROXY_NO_BIG_CARD)) { this.m_historyBlocking = true; this.m_historyBlockingTaskList = this.m_currentTaskList; HistoryManager.Get().CreateTriggeredBigCard(entity6, new HistoryManager.FinishedCallback(this.OnBigCardFinished)); } } else { if (this.ShouldShowTriggeredBigCard(triggeredEntity)) { this.m_historyBlocking = true; this.m_historyBlockingTaskList = this.m_currentTaskList; HistoryManager.Get().CreateTriggeredBigCard(triggeredEntity, new HistoryManager.FinishedCallback(this.OnBigCardFinished)); } HistoryManager.Get().CreateTriggerTile(triggeredEntity); } this.m_currentTaskList.SetSpawnedHistoryTile(true); } } if (this.m_currentTaskList.DidBlockSpawnHistoryTile()) { this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } } } } else if (sourceAction.BlockType == HistoryBlock.Type.FATIGUE) { if (this.m_currentTaskList.IsSourceActionOrigin()) { HistoryManager.Get().CreateFatigueTile(); this.m_currentTaskList.SetSpawnedHistoryTile(true); } this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } } else { AttackType attackType = this.m_currentTaskList.GetAttackType(); Entity attacker = null; Entity defender = null; switch (attackType) { case AttackType.REGULAR: attacker = this.m_currentTaskList.GetAttacker(); defender = this.m_currentTaskList.GetDefender(); break; case AttackType.CANCELED: attacker = this.m_currentTaskList.GetAttacker(); defender = this.m_currentTaskList.GetProposedDefender(); break; } if ((attacker != null) && (defender != null)) { HistoryManager.Get().CreateAttackTile(attacker, defender, this.m_currentTaskList); this.m_currentTaskList.SetSpawnedHistoryTile(true); this.m_currentTaskList.NotifyHistoryOfAdditionalTargets(); } } } }
private bool DoTaskListWithSpellController(GameState state, PowerTaskList taskList, Entity sourceEntity) { Network.HistActionStart sourceAction = taskList.GetSourceAction(); switch (sourceAction.BlockType) { case HistoryBlock.Type.ATTACK: { AttackSpellController spellController = this.CreateAttackSpellController(taskList); if (!this.DoTaskListUsingController(spellController, taskList, new SpellController.FinishedCallback(this.OnSpellControllerFinished))) { this.DestroySpellController(spellController); return(false); } return(true); } case HistoryBlock.Type.POWER: { PowerSpellController controller2 = this.CreatePowerSpellController(taskList); if (!this.DoTaskListUsingController(controller2, taskList, new SpellController.FinishedCallback(this.OnSpellControllerFinished))) { this.DestroySpellController(controller2); return(false); } return(true); } case HistoryBlock.Type.TRIGGER: if (sourceEntity.IsSecret()) { SecretSpellController controller3 = this.CreateSecretSpellController(taskList); if (!this.DoTaskListUsingController(controller3, taskList, new SpellController.FinishedCallback(this.OnSpellControllerFinished))) { this.DestroySpellController(controller3); return(false); } } else { TriggerSpellController controller4 = this.CreateTriggerSpellController(taskList); Card card = sourceEntity.GetCard(); if (TurnStartManager.Get().IsCardDrawHandled(card)) { if (!controller4.AttachPowerTaskList(taskList)) { this.DestroySpellController(controller4); return(false); } controller4.AddFinishedTaskListCallback(new SpellController.FinishedTaskListCallback(this.OnSpellControllerFinishedTaskList)); controller4.AddFinishedCallback(new SpellController.FinishedCallback(this.OnSpellControllerFinished)); TurnStartManager.Get().NotifyOfSpellController(controller4); } else if (!this.DoTaskListUsingController(controller4, taskList, new SpellController.FinishedCallback(this.OnSpellControllerFinished))) { this.DestroySpellController(controller4); return(false); } } return(true); case HistoryBlock.Type.DEATHS: { DeathSpellController controller5 = this.CreateDeathSpellController(taskList); if (!this.DoTaskListUsingController(controller5, taskList, new SpellController.FinishedCallback(this.OnSpellControllerFinished))) { this.DestroySpellController(controller5); return(false); } return(true); } case HistoryBlock.Type.FATIGUE: { FatigueSpellController controller6 = this.CreateFatigueSpellController(taskList); if (!controller6.AttachPowerTaskList(taskList)) { this.DestroySpellController(controller6); return(false); } controller6.AddFinishedTaskListCallback(new SpellController.FinishedTaskListCallback(this.OnSpellControllerFinishedTaskList)); controller6.AddFinishedCallback(new SpellController.FinishedCallback(this.OnSpellControllerFinished)); if (state.IsTurnStartManagerActive()) { TurnStartManager.Get().NotifyOfSpellController(controller6); } else { controller6.DoPowerTaskList(); } return(true); } case HistoryBlock.Type.JOUST: { JoustSpellController controller7 = this.CreateJoustSpellController(taskList); if (!this.DoTaskListUsingController(controller7, taskList, new SpellController.FinishedCallback(this.OnSpellControllerFinished))) { this.DestroySpellController(controller7); return(false); } return(true); } } object[] args = new object[] { sourceAction.BlockType, sourceEntity }; Log.Power.Print("PowerProcessor.DoTaskListForCard() - actionStart has unhandled BlockType {0} for sourceEntity {1}", args); return(false); }