public static void AccessoryGuard(Timeline t, CombatUnit caster, CombatUnit targetUnit) { float targetFacing = targetUnit.transform.eulerAngles.y; t.gameObject.AddComponent <FaceTile_TimelineEvent>().Init(t, 0, targetUnit.GetComponent <Facer>(), caster.GetComponent <TileOccupier>().GetOccupiedTile()); t.gameObject.AddComponent <Shimmy_TimelineEvent>().Init(t, .05f, targetUnit.gameObject); t.gameObject.AddComponent <FlyingText_TimelineEvent>().Init(t, .35f, "MISS", targetUnit); t.gameObject.AddComponent <FaceAngle_TimelineEvent>().Init(t, .55f, targetUnit.GetComponent <Facer>(), targetFacing); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .55f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.Advance(.55f); }
public static void WeaponGuard(Timeline t, CombatUnit caster, CombatUnit targetUnit) { float targetFacing = targetUnit.transform.eulerAngles.y; t.gameObject.AddComponent <FaceTile_TimelineEvent>().Init(t, 0, targetUnit.GetComponent <Facer>(), caster.GetComponent <TileOccupier>().GetOccupiedTile()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0, "Armature|ShieldBlock", targetUnit.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0, "Armature|SwordAttackBlocked", caster.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <PlaySound_TimelineEvent>().Init(t, 0, "shield_block"); t.gameObject.AddComponent <FlyingText_TimelineEvent>().Init(t, .35f, "GUARDED", targetUnit); t.gameObject.AddComponent <FaceAngle_TimelineEvent>().Init(t, .55f, targetUnit.GetComponent <Facer>(), targetFacing); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .55f, targetUnit.GetDefaultAnimation(), targetUnit.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .75f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.Advance(.75f); }
private void OnTriggerEnter(Collider other) { UnitController otherUC = other.GetComponent <UnitController>(); if (null == m_parentCombatUnit) { return; } UnitController parentUC = m_parentCombatUnit.GetComponent <UnitController>(); if (null == otherUC || null == parentUC || !other.gameObject.GetComponent <NavMeshAgent>().isActiveAndEnabled) { return; } if (otherUC.GetPlayerNumber() != parentUC.GetPlayerNumber()) { m_parentCombatUnit.UnitEnterAggroRange(other.GetComponent <CombatUnit>()); } }
public static void UseWeapon(Timeline t, CombatUnit caster, Tile targetTile) { t.gameObject.AddComponent <FaceTile_TimelineEvent>().Init(t, 0, caster.GetComponent <Facer>(), targetTile); Weapon w = Engine.CombatManager.WeaponTable[caster.Weapon]; switch (w.Type) { case "Sword": case "Knife": SwingSword(t, caster, targetTile); break; case "Bow": FireBow(t, caster, targetTile); break; } }
public static void ThrowStone(CombatUnit caster, Tile targetTile, CombatUnit targetUnit) { Action action = Engine.CombatManager.ActionTable["ThrowStone"]; Timeline t = new GameObject("Throw Stone Timeline").AddComponent <Timeline>(); t.gameObject.AddComponent <CameraFocus_TimelineEvent>().Init(t, 0, caster.transform.position, .5f); t.Advance(.5f); t.gameObject.AddComponent <Message_TimelineEvent>().Init(t, 0, "Effect", action.GetName()); t.Advance(.15f); t.gameObject.AddComponent <FaceTile_TimelineEvent>().Init(t, 0, caster.GetComponent <Facer>(), targetTile); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0, "Armature|SwordAttack", caster.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <PlaySound_TimelineEvent>().Init(t, 0, "sword_swing"); t.Advance(.25f); // Moment of impact TileOccupier tO = TileOccupier.GetTileOccupant(targetTile); if (tO != null) { targetUnit = tO.GetComponent <CombatUnit>(); int damage = Action.Mod2(caster.PA, false, Element.None, caster, targetUnit, System.Reflection.MethodBase.GetCurrentMethod().Name); targetUnit.TakeDamage(damage); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0f, "Armature|Hurt", targetUnit.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <PlaySound_TimelineEvent>().Init(t, 0, "slash"); t.gameObject.AddComponent <SpawnEffect_TimelineEvent>().Init(t, .2f, "PhysicalDamage", targetTile); t.gameObject.AddComponent <FlyingText_TimelineEvent>().Init(t, .35f, damage.ToString(), targetUnit); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .55f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .55f, targetUnit.GetDefaultAnimation(), targetUnit.GetComponentInChildren <Animator>()); t.Advance(.55f); } else { t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 1f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); } t.gameObject.AddComponent <DestroyTimeline_TimelineEvent>().Init(t, .25f); t.PlayFromStart(); }
public static void Fire(CombatUnit caster, Tile targetTile, CombatUnit targetUnit) { Action action = Engine.CombatManager.ActionTable["Fire"]; Timeline t = new GameObject("Fire Timeline").AddComponent <Timeline>(); t.gameObject.AddComponent <CameraFocus_TimelineEvent>().Init(t, 0, caster.transform.position, .5f); t.Advance(.5f); t.gameObject.AddComponent <Message_TimelineEvent>().Init(t, 0, "Effect", action.GetName()); t.Advance(.15f); t.gameObject.AddComponent <FaceTile_TimelineEvent>().Init(t, 0, caster.GetComponent <Facer>(), targetTile); t.Advance(.25f); // Moment of impact List <Tile> affected = action.AffectedTiles(targetTile, new List <Tile>()); foreach (Tile affectedTile in affected) { TileOccupier tO = TileOccupier.GetTileOccupant(affectedTile); if (tO != null) { targetUnit = tO.GetComponent <CombatUnit>(); int damage = Action.Mod5(Element.Fire, 14, caster, targetUnit); targetUnit.TakeDamage(damage); t.gameObject.AddComponent <CameraFocus_TimelineEvent>().Init(t, 0, tO.transform.position, .25f); t.gameObject.AddComponent <SpawnEffect_TimelineEvent>().Init(t, .25f, "Fire", tO.GetOccupiedTile()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 1.25f, "Armature|Hurt", tO.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <FlyingText_TimelineEvent>().Init(t, 2.25f, damage.ToString(), tO); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 3.75f, targetUnit.GetDefaultAnimation(), targetUnit.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 3.75f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.Advance(3.75f); } } t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <DestroyTimeline_TimelineEvent>().Init(t, .25f); t.PlayFromStart(); }
public static void HitDamage(Timeline t, CombatUnit caster, CombatUnit targetUnit, int damage) { targetUnit.TakeDamage(damage); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0f, "Armature|Hurt", targetUnit.GetComponentInChildren <Animator>()); WeaponHitSound(t, caster); t.gameObject.AddComponent <SpawnEffect_TimelineEvent>().Init(t, .2f, "PhysicalDamage", targetUnit.GetComponent <TileOccupier>().GetOccupiedTile()); t.gameObject.AddComponent <FlyingText_TimelineEvent>().Init(t, .35f, damage.ToString(), targetUnit); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .55f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .55f, targetUnit.GetDefaultAnimation(), targetUnit.GetComponentInChildren <Animator>()); t.Advance(.55f); }
public static void StasisSword(CombatUnit caster, Tile targetTile, CombatUnit targetUnit) { string action_id = System.Reflection.MethodBase.GetCurrentMethod().Name; Action action = Engine.CombatManager.ActionTable[action_id]; Timeline t = ActionPatterns.Start(action, true); ActionPatterns.UseWeapon(t, caster, targetTile); List <Tile> exclude = new List <Tile>(); exclude.Add(caster.gameObject.GetComponent <TileOccupier>().GetOccupiedTile()); List <Tile> affected = action.AffectedTiles(targetTile, exclude); foreach (Tile affectedTile in affected) { targetUnit = ActionPatterns.TargetUnit(affectedTile); if (targetUnit) { bool critical = Action.GetCritical(); int damage = Action.Mod2(caster.PA, critical, Element.None, caster, targetUnit, action_id); targetUnit.TakeDamage(damage); t.gameObject.AddComponent <CameraFocus_TimelineEvent>().Init(t, 0, targetUnit.transform.position, .25f); t.gameObject.AddComponent <SpawnEffect_TimelineEvent>().Init(t, .25f, "StasisSword", targetUnit.GetComponent <TileOccupier>().GetOccupiedTile()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 1.25f, "Armature|Hurt", targetUnit.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <PlaySound_TimelineEvent>().Init(t, 1.25f, "clang"); t.gameObject.AddComponent <FlyingText_TimelineEvent>().Init(t, 2.25f, damage.ToString(), targetUnit); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 3.75f, targetUnit.GetDefaultAnimation(), targetUnit.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 3.75f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.Advance(3.75f); } } t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, .25f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>()); t.gameObject.AddComponent <DestroyTimeline_TimelineEvent>().Init(t, .25f); t.PlayFromStart(); }