private void AssignDamageToAttackers() { foreach (GameObject card in GameManager.Instance.MinionsAttacking) { CardVisual cv = card.GetComponent <CardVisual>(); ConditionListener cl = card.GetComponent <ConditionListener>(); if (cv.Md != null && cl != null) { if ((cl.ConditionEvent == EVENT_TYPE.BLEED || cl.ConditionEvent == EVENT_TYPE.MINION_DEFEATED) && (cv.CurrentHealth - 1) == 0) { minionsLeft.Add(cv); } else { cv.AdjustHealth(1, false); } } else { cv.AdjustHealth(1, false); } } if (minionsLeft.Count > 0) { attackAfter = true; } GameManager.Instance.MinionsAttacking.Clear(); }
public void AssignDamageToAttackers() { foreach (Transform card in GameManager.Instance.GetActiveMinionZone(true)) { CardVisual cv = card.GetComponent <CardVisual>(); if (cv.IsTapped && !cv.TapEffect) { if (cv.Md != null) { if ((cv.Md.ConditionID == 1 && (cv.CurrentHealth - 1) == 0) || (cv.Md.ConditionID == 3 && (cv.CurrentHealth - 1) == 0)) { continue; } else { cv.AdjustHealth(1, false); } } else { cv.AdjustHealth(1, false); } } } }
public void OnPointerDown(PointerEventData eventData) { GameObject card = eventData.pointerCurrentRaycast.gameObject.transform.parent.gameObject; CardVisual cv = card.GetComponent <CardVisual>(); if (cv.IsPromoted && (cv.CurrentHealth < cv.PromotedHealth)) { StartCoroutine(GameManager.Instance.SetInstructionsText("Minion's Health Increased by 1")); //Adjust Damage cv.AdjustHealth(1, true); //Set Health Flag to true cv.HealEffect = true; //Remove Listener StartCoroutine(RemoveListener()); } else if (cv.CurrentHealth < cv.TotalHealth && !cv.IsPromoted) { StartCoroutine(GameManager.Instance.SetInstructionsText("Minion's Health Increased by 1")); //Adjust Damage cv.AdjustHealth(1, true); //Set Health Flag to true cv.HealEffect = true; //Remove Listener StartCoroutine(RemoveListener()); } else { StartCoroutine(GameManager.Instance.SetInstructionsText("Minion is already at Max Health")); } }
public IEnumerator InvokeDelay(InvokeEventCommand iec) { ConditionListener cl = iec.card.GetComponent <ConditionListener>(); int position = iec.card.transform.GetSiblingIndex(); object[] data = new object[] { position }; if (!StartGameController.Instance.tutorial) { if (cl.ConditionEvent == EVENT_TYPE.TAP_MINION) { PhotonNetwork.RaiseEvent(TAP_ANIMATION_SYNC_EVENT, data, new RaiseEventOptions { Receivers = ReceiverGroup.Others }, SendOptions.SendReliable); } else { PhotonNetwork.RaiseEvent(ANIMATION_SYNC_EVENT, data, new RaiseEventOptions { Receivers = ReceiverGroup.Others }, SendOptions.SendReliable); } } DelayCommand dc = new DelayCommand(iec.card.transform, 2f); dc.AddToQueue(); GameManager.Instance.effectText.gameObject.SetActive(true); yield return(new WaitForSeconds(2.5f)); GameManager.Instance.effectText.gameObject.SetActive(false); iec.method.Invoke(iec.cardType, new object[] { }); CardVisual cv = iec.card.GetComponent <CardVisual>(); if (!StartGameController.Instance.tutorial) { if (cl.ConditionEvent == EVENT_TYPE.TAP_MINION && InvokeEventCommand.InvokeEventQueue.Count == 0) { cv.AdjustHealth(1, false); } } else { if (InvokeEventCommand.InvokeEventQueue.Count == 0) { cv.AdjustHealth(1, false); } } }
private void AssignDamageToDefenders(List <DamagePhoton> damages, Dictionary <string, int> heroDamage) { int i = 0; foreach (Transform t in GameManager.Instance.GetActiveMinionZone(false)) { CardVisual cv = t.GetComponent <CardVisual>(); DamagePhoton damage = damages[i]; foreach (KeyValuePair <string, int> entry in damage.DamageAbsorbed) { if (entry.Value != 0) { if (entry.Key.Equals("poisonTouch") && (cv.Sd || cv.Md.EffectId1 != 9)) { cv.AdjustHealth(cv.CurrentHealth, false); } else { cv.AdjustHealth(entry.Value, false); } } } if (cv.CurrentHealth > 0) { cv.DmgAbsorbed.ResetDamageAbsorbed(); cv.ResetDamageObjectsUI(); } i++; } foreach (KeyValuePair <string, int> entry in heroDamage) { if (entry.Value != 0) { GameManager.Instance.ActiveHero(false).AdjustHealth(entry.Value, false); if (entry.Key.Equals("lifesteal")) { GameManager.Instance.ActiveHero(true).AdjustHealth(entry.Value, true); EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.POWER_LIFESTEAL); } else if (entry.Key.Equals("poisonTouch")) { EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.POWER_POISON_TOUCH); } else if (entry.Key.Equals("stealth")) { EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.POWER_STEALTH); } } } }
private IEnumerator PromoteMinion(Transform card, CardVisual cv) { yield return(new WaitForSeconds(1)); int cost = int.Parse(cv.cost.text); GameManager.Instance.ActiveHero(true).AdjustMana(cost, false); DelayCommand dc = new DelayCommand(GameManager.Instance.GetActiveHand(true), 1f); dc.AddToQueue(); yield return(new WaitForSeconds(1)); MoveCardCommand mc = new MoveCardCommand(card.gameObject, GameManager.Instance.GetActiveMinionZone(true)); mc.AddToQueue(); cv.AdjustHealth(2, true); cv.PromotedHealth = cv.CurrentHealth; if (cv.Md != null) { RemoveCardFromHand(cv.Md); } else { RemoveCardFromHand(cv.Sd); } card.Find("CardBack").gameObject.SetActive(false); }
public void OnPointerDown(PointerEventData eventData) { GameObject card = eventData.pointerCurrentRaycast.gameObject.transform.parent.gameObject; CardVisual cv = card.GetComponent <CardVisual>(); if (cv.CurrentHealth - 1 == 0) { EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.MINION_DEFEATED); } cv.AdjustHealth(1, false); //Multiplayer int position = gameObject.transform.GetSiblingIndex(); if (!StartGameController.Instance.tutorial) { object[] data = new object[] { position, 1, false, false }; EffectCommandPun.Instance.SendData(ADJUST_HEALTH_SYNC_EVENT, data); } foreach (Transform t in GameManager.Instance.GetActiveMinionZone(false)) { ShockListener sl = t.GetComponent <ShockListener>(); if (sl) { Destroy(sl); } } if (GameManager.Instance.InHeroPower) { GameManager.Instance.InHeroPower = false; EffectCommand.Instance.inEffect = false; } else { //Call the Next Power in the Queue InvokeEventCommand.InvokeNextEvent(); UIManager.Instance.RemoveEffectIcon = true; } if (StartGameController.Instance.tutorial) { StartGameController.Instance.TutorialObject.GetComponent <TutorialTextController>().ShowUI(); } }
private void MoveCardFromHand(bool isMinion) { bool promote = false; DelayCommand dc = new DelayCommand(GameManager.Instance.GetActiveHand(true), 1f); dc.AddToQueue(); card = gameObject; CardVisual cv = card.GetComponent <CardVisual>(); byte[] cardByte; MinionDataPhoton mdp; StarterDataPhoton sdp; EssentialsDataPhoton edp; string type; if (isMinion) { Card cardData = card.GetComponent <CardVisual>().CardData; if (UIManager.Instance.GetActiveHandList(true).Contains(cardData)) { UIManager.Instance.GetActiveHandList(true).Remove(cardData); } if (GameManager.Instance.IsPromoting) { card = GameManager.Instance.MinionToPromote; StartOrCancelPromotionEvent(false); summonPanel.SetActive(false); cv.AdjustHealth(2, true); cv.IsPromoted = true; cv.PromotedHealth = cv.CurrentHealth; promote = true; } MoveCardCommand mc = new MoveCardCommand(card, GameManager.Instance.GetActiveMinionZone(true)); mc.AddToQueue(); //Add Condition Scripts if (thisCard is MinionData) { GameManager.Instance.GetComponent <ConditionAndEffectAssigner>().Md = thisCard as MinionData; GameManager.Instance.GetComponent <ConditionAndEffectAssigner>().Card = card; EventManager.Instance.PostNotification(EVENT_TYPE.ASSIGN_CONDITIONS); } if (!StartGameController.Instance.tutorial) { if (thisCard is MinionData) { mdp = new MinionDataPhoton(cv.Md); cardByte = DataHandler.Instance.ObjectToByteArray(mdp); type = "Minion"; } else { sdp = new StarterDataPhoton(cv.Sd); cardByte = DataHandler.Instance.ObjectToByteArray(sdp); type = "Starter"; } object[] data = new object[] { cardByte, type }; if (!promote) { PlayCardPun.Instance.SendData(PLAY_MINION, data); } else { PlayCardPun.Instance.SendData(PROMOTE_MINION, data); } } } else { Card cardData = card.GetComponent <CardVisual>().CardData; if (UIManager.Instance.GetActiveHandList(true).Contains(cardData)) { UIManager.Instance.GetActiveHandList(true).Remove(cardData); } //GameManager.Instance.MoveCard(card, GameManager.Instance.GetActiveDiscardPile(true), GameManager.Instance.GetActiveDiscardPileList(true), true); int position = 0; if (thisCard is StarterData) { position = gameObject.transform.GetSiblingIndex(); type = "Starter"; } else { position = gameObject.transform.GetSiblingIndex(); type = "Essential"; } if (!StartGameController.Instance.tutorial) { object[] data = new object[] { position, type }; PlayCardPun.Instance.SendData(PLAY_RESOURCE, data); } MoveCardCommand mc = new MoveCardCommand(card, GameManager.Instance.GetActiveDiscardPile(true), UIManager.Instance.GetActiveDiscardList(true)); mc.AddToQueue(); } AdjustHeroResources(); }
private void OnEvent(EventData photonEvent) { byte eventCode = photonEvent.Code; if (eventCode == START_COMBAT) { object[] data = (object[])photonEvent.CustomData; int[] damages = (int[])data[0]; List <CardPhoton> cards = (List <CardPhoton>)DataHandler.Instance.ByteArrayToObject((byte[])data[1]); bool heroAttacking = (bool)data[2]; if (heroAttacking) { GameManager.Instance.ActiveHero(true).AdjustMana(GameManager.Instance.ActiveHero(true).Damage, false); } TapMinions(cards); GameManager.Instance.StartCombatDamageUI.gameObject.SetActive(true); GameManager.Instance.alliedStealthDamageCounter.text = damages[0].ToString(); GameManager.Instance.alliedLifestealDamageCounter.text = damages[1].ToString(); GameManager.Instance.alliedPoisonTouchDamageCounter.text = damages[2].ToString(); GameManager.Instance.alliedDamageCounter.text = damages[3].ToString(); StartCombat sc = GameManager.Instance.ActiveHero(true).AttackButton.parent.GetComponent <StartCombat>(); sc.totalDamage = new Dictionary <string, int> { { "stealth", damages[0] }, { "lifesteal", damages[1] }, { "poisonTouch", damages[2] }, { "damage", damages[3] } }; EventManager.Instance.PostNotification(EVENT_TYPE.DEFEND_AGAINST); GameManager.Instance.shopButton.interactable = false; } else if (eventCode == ASSIGN_DEFENDING_DAMAGE) { object[] data = (object[])photonEvent.CustomData; List <DamagePhoton> damageToAssign = (List <DamagePhoton>)DataHandler.Instance.ByteArrayToObject((byte[])data[0]); Dictionary <string, int> heroDamage = (Dictionary <string, int>)DataHandler.Instance.ByteArrayToObject((byte[])data[1]); bool minionDefeated = (bool)data[2]; int totalHeroDamage = 0; foreach (KeyValuePair <string, int> entry in heroDamage) { totalHeroDamage += entry.Value; } AssignDamageToDefenders(damageToAssign, heroDamage); if (totalHeroDamage > 0) { //Add Bleed to the queue EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.BLEED); } if (minionDefeated) { //Add Minion Defeated to the queue EffectCommand.Instance.EffectQueue.Enqueue(EVENT_TYPE.MINION_DEFEATED); } GameManager.Instance.IsDefending = false; AssignDamageToAttackers(); DefendListener dl = GameManager.Instance.GetComponent <DefendListener>(); dl.ChangeUiForDefense(GameManager.Instance.IsDefending); GameManager.Instance.EnableOrDisablePlayerControl(true); GameManager.Instance.endButton.interactable = true; dl.ResetDamageUI(); StartCombat sc = GameManager.Instance.ActiveHero(true).AttackButton.parent.GetComponent <StartCombat>(); sc.totalDamage = new Dictionary <string, int> { { "stealth", 0 }, { "lifesteal", 0 }, { "poisonTouch", 0 }, { "damage", 0 } }; GameManager.Instance.instructionsObj.GetComponent <TMP_Text>().text = ""; } else if (eventCode == ASSIGN_AFTER_EFFECT_SYNC_EVENT) { object[] data = (object[])photonEvent.CustomData; int[] minions = (int[])data[0]; int i = 0; foreach (Transform card in GameManager.Instance.GetActiveMinionZone(true)) { CardVisual cv = card.GetComponent <CardVisual>(); if (cv.Md.MinionID == minions[i]) { cv.AdjustHealth(1, false); } i++; } } }
private void OnEvent(EventData photonData) { byte eventCode = photonData.Code; if (eventCode == TAP_ANIMATION_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int index = (int)data[0]; Transform card = GameManager.Instance.GetActiveMinionZone(true).GetChild(index); CardVisual cv = card.GetComponent <CardVisual>(); cv.IsTapped = true; cv.ChangeTappedAppearance(); DelayCommand dc = new DelayCommand(card, 2f); dc.AddToQueue(); StartCoroutine(ShowEffectAnimation()); cv.AdjustHealth(1, false); } else if (eventCode == ANIMATION_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int index = (int)data[0]; Transform card = GameManager.Instance.GetActiveMinionZone(true).GetChild(index); DelayCommand dc = new DelayCommand(card, 2f); dc.AddToQueue(); StartCoroutine(ShowEffectAnimation()); } else if (eventCode == PEEK_SHOP_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; string cardClass = (string)data[0]; int[] cards = (int[])data[1]; List <MinionData> cardList = new List <MinionData>(); foreach (int id in cards) { MinionData minion = Resources.Load("Minions/" + id) as MinionData; cardList.Add(minion); } UIManager.Instance.MoveTopCardsToBottom(cardClass, cardList); } else if (eventCode == ADJUST_HEALTH_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int position = (int)data[0]; int healthAmount = (int)data[1]; bool increaseOrDecrease = (bool)data[2]; bool activeOrInactive = (bool)data[3]; Transform card = GameManager.Instance.GetActiveMinionZone(activeOrInactive).GetChild(position); CardVisual cv = card.GetComponent <CardVisual>(); cv.AdjustHealth(healthAmount, increaseOrDecrease); } else if (eventCode == ADJUST_DAMAGE_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int position = (int)data[0]; int damageAmount = (int)data[1]; bool increaseOrDecrease = (bool)data[2]; Transform card = GameManager.Instance.GetActiveMinionZone(true).GetChild(position); CardVisual cv = card.GetComponent <CardVisual>(); cv.AdjustDamage(damageAmount, increaseOrDecrease); } else if (eventCode == ADJUST_GOLD_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int amount = (int)data[0]; GameManager.Instance.ActiveHero(true).AdjustGold(2, true); } else if (eventCode == ADJUST_EXP_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int amount = (int)data[0]; GameManager.Instance.ActiveHero(true).EnemyGainExp(2); } else if (eventCode == ADJUST_HERO_HEALTH_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int amount = (int)data[0]; GameManager.Instance.ActiveHero(false).AdjustHealth(amount, false); } else if (eventCode == DRAW_DISCARD_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int position = (int)data[0]; Transform card = GameManager.Instance.GetActiveHand(true).GetChild(position); GameManager.Instance.DiscardCard(card.gameObject); } else if (eventCode == ACTIVATE_SILENCE_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int position = (int)data[0]; Transform card = GameManager.Instance.GetActiveMinionZone(false).GetChild(position); CardVisual cv = card.GetComponent <CardVisual>(); cv.ActivateSilence(true); } else if (eventCode == ADJUST_DISCARD_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; bool increase = (bool)data[0]; GameManager.Instance.ActiveHero(false).AdjustEnemyDiscard(increase); } else if (eventCode == ANIMATION_MESSAGE_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; string message = (string)data[0]; StartCoroutine(ShowEffectAnimation(message)); } else if (eventCode == COMBAT_EFFECT_SYNC_EVENT) { object[] data = (object[])photonData.CustomData; int position = (int)data[0]; bool enableOrDisable = (bool)data[1]; string to = (string)data[2]; Transform card; if (to.Equals("Hand")) { card = GameManager.Instance.GetActiveHand(true).GetChild(position); } else { card = GameManager.Instance.GetActiveMinionZone(true).GetChild(position); } CardVisual cv = card.GetComponent <CardVisual>(); cv.IsCombatEffectActivated = enableOrDisable; cv.CombatEffectActivated(enableOrDisable); } }
private void MoveCardFromHand(bool isMinion) { DelayCommand dc = new DelayCommand(GameManager.Instance.GetActiveHand(true), 1f); dc.AddToQueue(); card = gameObject; CardVisual cv = card.GetComponent <CardVisual>(); if (isMinion) { Card cardData = card.GetComponent <CardVisual>().CardData; if (UIManager.Instance.GetActiveHandList(true).Contains(cardData)) { UIManager.Instance.GetActiveHandList(true).Remove(cardData); } if (GameManager.Instance.IsPromoting) { card = GameManager.Instance.MinionToPromote; StartOrCancelPromotionEvent(false); summonPanel.SetActive(false); cv.AdjustHealth(2, true); cv.IsPromoted = true; cv.PromotedHealth = cv.CurrentHealth; } MoveCardCommand mc = new MoveCardCommand(card, GameManager.Instance.GetActiveMinionZone(true)); mc.AddToQueue(); //Add Condition Scripts if (thisCard is MinionData) { //GameManager.Instance.GetComponent<ConditionAndEffectAssigner>().Md = thisCard as MinionData; //GameManager.Instance.GetComponent<ConditionAndEffectAssigner>().Card = card; //EventManager.Instance.PostNotification(EVENT_TYPE.ASSIGN_CONDITIONS); gameObject.AddComponent <TutorialConditionListener>(); gameObject.GetComponent <TutorialConditionListener>().ConditionEvent = EVENT_TYPE.TAP_MINION; if (thisCard.MinionID == 4) { gameObject.AddComponent <DrawCardListener>(); } else if (thisCard.MinionID == 101) { gameObject.AddComponent <BuffMinionStarter>(); gameObject.AddComponent <EssentialListener>(); gameObject.GetComponent <EssentialListener>().Type = "Gold"; } gameObject.GetComponent <TutorialConditionListener>().Card = gameObject; gameObject.GetComponent <TutorialConditionListener>().Md = thisCard as MinionData; gameObject.GetComponent <TutorialConditionListener>().enabled = true; } cv.particleGlow.gameObject.SetActive(false); } else { Card cardData = card.GetComponent <CardVisual>().CardData; if (UIManager.Instance.GetActiveHandList(true).Contains(cardData)) { UIManager.Instance.GetActiveHandList(true).Remove(cardData); } MoveCardCommand mc = new MoveCardCommand(card, GameManager.Instance.GetActiveDiscardPile(true), UIManager.Instance.GetActiveDiscardList(true)); mc.AddToQueue(); //GameManager.Instance.MoveCard(card, GameManager.Instance.GetActiveDiscardPile(true), GameManager.Instance.GetActiveDiscardPileList(true), true); } AdjustHeroResources(); //Increase Count in TutorialUI int count = StartGameController.Instance.TutorialObject.GetComponent <TutorialTextController>().count; int maxCount = StartGameController.Instance.TutorialObject.GetComponent <TutorialTextController>().maxCount; if (count < maxCount) { StartGameController.Instance.TutorialObject.GetComponent <TutorialTextController>().count++; } else { StartGameController.Instance.TutorialObject.GetComponent <TutorialTextController>().ShowUI(); } TutorialPlayCard tpc = gameObject.GetComponent <TutorialPlayCard>(); Destroy(tpc); }