public GameObject CreateWaveAnimationObject(float lifetime, int wave) { GameObject go = new GameObject("Wave Animation (" + wave + ")"); go.AddComponent <RectTransform>(); go.transform.SetParent(CanvasToUse.transform); go.GetComponent <RectTransform>().offsetMin = Vector2.zero; go.GetComponent <RectTransform>().offsetMax = Vector2.zero; go.GetComponent <RectTransform>().localScale = Vector3.one; go.GetComponent <RectTransform>().anchorMin = new Vector2(0.2f, 0.4f); go.GetComponent <RectTransform>().anchorMax = new Vector2(0.8f, 0.6f); Text t = go.AddComponent <Text>(); t.text = "Wave " + wave; t.color = Color.red; t.font = FontToUse; t.fontSize = 30; t.alignment = TextAnchor.MiddleCenter; Outline ol = go.AddComponent <Outline>(); ol.effectColor = Color.white; ol.effectDistance = new Vector2(1, 1); CombatAnimation ca = go.AddComponent <CombatAnimation>(); ca.Lifetime = lifetime; ca.RiseOverTime = true; return(go); }
public override void OnCreatureAttacked(CreatureAttackedMessage msg) { base.OnCreatureAttacked(msg); var attackingCard = opponentBoardCards.Find(x => x.card.instanceId == msg.attackingCardInstanceId); var attackedCard = playerBoardCards.Find(x => x.card.instanceId == msg.attackedCardInstanceId); if (attackingCard != null && attackedCard != null) { CombatAnimation.PlayFightAnimation(attackingCard.gameObject, attackedCard.gameObject, 0.5f, () => { effectSolver.FightCreature(msg.attackingPlayerNetId, attackingCard.card, attackedCard.card); }); } }
public override void OnPlayerAttacked(PlayerAttackedMessage msg) { base.OnPlayerAttacked(msg); var attackingCard = opponentBoardCards.Find(x => x.card.instanceId == msg.attackingCardInstanceId); if (attackingCard != null) { CombatAnimation.PlayFightAnimation(attackingCard.gameObject, GameObject.Find("Player/Avatar"), 0.1f, () => { effectSolver.FightPlayer(msg.attackingPlayerNetId, msg.attackingCardInstanceId); }); } }
public GameObject CreateCombatAnimationObject(float lifetime, string text, bool leftSide, Color color, bool rise) { GameObject go = new GameObject("Combat Animation (" + text + ")"); go.AddComponent <RectTransform>(); go.transform.SetParent(CanvasToUse.transform); Vector2 position; if (leftSide) { position = Camera.main.WorldToViewportPoint(Player.Instance.transform.position); } else { position = Camera.main.WorldToViewportPoint(CombatSystem.Instance.CurrentEnemy.transform.position); } position.y += 0.1f; go.GetComponent <RectTransform>().offsetMin = Vector2.zero; go.GetComponent <RectTransform>().offsetMax = Vector2.zero; go.GetComponent <RectTransform>().localScale = Vector3.one; go.GetComponent <RectTransform>().anchorMin = position; go.GetComponent <RectTransform>().anchorMax = position; go.GetComponent <RectTransform>().sizeDelta = new Vector2(1280, 720); Text t = go.AddComponent <Text>(); t.text = text; t.color = color; t.font = FontToUse; t.fontSize = FontSize; t.alignment = TextAnchor.MiddleCenter; Outline ol = go.AddComponent <Outline>(); ol.effectColor = Color.white; ol.effectDistance = new Vector2(1, 1); CombatAnimation ca = go.AddComponent <CombatAnimation>(); ca.Lifetime = lifetime; ca.RiseOverTime = rise; return(go); }
/// <summary> /// This method sets up the new combat input to be processed. /// </summary> private void SetupCombatInputForProcessing() { // Condition for adding a new input to be processed if (_combatInputs.Count != 0 && !_isCurrentCombatProcessing && _combatState == CombatState.SetupInput) { _currentCombatInfo = _combatInputs.Dequeue(); // Getting the next CombatInfo _combatState = CombatState.Processing; // Start the processing of the input _isCurrentCombatProcessing = true; // Current CombatInfo is being processed _isAcceptInputThreshold = false; // Accepting input threshold resetted _currentAnimationTime = 0; // Resetting current animation timer for further use // Playing the attack animation PlayAttackAnimation(_currentCombatInfo.AttackAnimation); } // Todo: Check if else condition is require as fail safe here }
public void ResolveCombat() { var sortingGroup = GetComponent <SortingGroup>(); if (fightTargetingArrow != null) { if (fightTargetingArrow.selectedPlayer != null) { var targetPlayer = fightTargetingArrow.selectedPlayer; SetHighlightingEnabled(false); isPlayable = false; sortingGroup.sortingOrder = 100; CombatAnimation.PlayFightAnimation(gameObject, targetPlayer.gameObject, 0.1f, () => { ownerPlayer.FightPlayer(card.instanceId); }, () => { sortingGroup.sortingOrder = 0; fightTargetingArrow = null; }); } if (fightTargetingArrow.selectedCard != null) { var targetCard = fightTargetingArrow.selectedCard; SetHighlightingEnabled(false); isPlayable = false; sortingGroup.sortingOrder = 100; if (targetCard != GetComponent <BoardCreature>() && targetCard.GetComponent <HandCard>() == null) { CombatAnimation.PlayFightAnimation(gameObject, targetCard.gameObject, 0.5f, () => { ownerPlayer.FightCreature(card, targetCard.card); }, () => { sortingGroup.sortingOrder = 0; fightTargetingArrow = null; }); } } } }
public void DoCombatAnimation(CombatAnimation anim, TweenCallback callback = null) { if (anim.jumpPoint) { var t = transform.DOJump(anim.jumpPoint.position, anim.jumpPower, 1, anim.jumpTime); if (audioSource && anim.audioClip) { audioSource.PlayOneShot(anim.audioClip); } if (animator) { animator.SetTrigger(anim.animTrigger); } if (callback != null) { t.onComplete += callback; } } }
void HandleAction(CharacterWrapper p1, CharacterWrapper p2, ref Equipment.Ability a1, ref Equipment.Ability a2, CombatAnimation ca1 = null, CombatAnimation ca2 = null) { switch (a1.action) { case Equipment.Action.none: break; case Equipment.Action.damage: if (ca1 != null) { ca1.PlayAttack(); } if (a2.action != Equipment.Action.block) { DoDamage(p2, a1.amount); if (ca2 != null) { ca2.PlayDamage(); } } else if (p2 == player) { reward += 15; } break; case Equipment.Action.damageStrength: if (ca1 != null) { ca1.PlayAttack(); } if (a2.action != Equipment.Action.block) { float damage = p1.strength * a1.amount; DoDamage(p2, damage); if (ca2 != null) { ca2.PlayDamage(); } } else if (p2 == player) { reward += 15; } break; case Equipment.Action.damageAgility: if (ca1 != null) { ca1.PlayAttack(); } if (a2.action != Equipment.Action.block) { float damage = p1.agility * a1.amount; DoDamage(p2, damage); if (ca2 != null) { ca2.PlayDamage(); } } else if (p2 == player) { reward += 15; } break; case Equipment.Action.block: if (ca1 != null) { ca1.PlayBlock(); } break; case Equipment.Action.cheer: if (ca1 != null) { ca1.PlayUtility(); } if (p1 == player) { reward += 30; } break; default: break; } }
/// <summary> /// This method gets a new attack information from the BasicAnimation class. /// </summary> protected virtual void GetNewAttackAnimation() { CurrentCombatInfo = GetAttackAnimation(); AttackTimer = 0; // Resetting attack timer for further use }