示例#1
0
    public static void FireBow(Timeline t, CombatUnit caster, Tile targetTile)
    {
        t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 0, "Armature|LongbowAttack", caster.GetComponentInChildren <Animator>());

        // Find out what and when the arrow will hit
        Vector3 arrowOrigin = caster.transform.position + new Vector3(0, .5f, 0);
        Vector3 arrowTarget = targetTile.transform.position + new Vector3(0, .5f, 0);
        float   distance    = Vector3.Distance(arrowOrigin, arrowTarget);
        int     resolution  = (int)Mathf.Ceil(distance * 3);
        float   arc         = ParabolicPath.MinimumArc(arrowOrigin, arrowTarget, 3, (int)Mathf.Ceil(distance * 3));

        float arrowFlightDuration    = (distance * (arc + 1) * .05f);
        Pair <CombatUnit, float> hit = ParabolicPath.ProjectileInterrupt(arrowOrigin, arrowTarget, arc, resolution);

        if (arc == 0)
        {
            arc = .25f;
        }
        t.gameObject.AddComponent <Projectile_TimelineEvent>().Init(t, .25f, caster.transform.position + new Vector3(0, 1, 0), targetTile.transform.position + new Vector3(0, 1, 0), arrowFlightDuration, arc, hit.second);
        t.Advance(.25f + arrowFlightDuration * hit.second);
    }
示例#2
0
 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);
 }
示例#3
0
    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);
    }
示例#4
0
 public static void SwingSword(Timeline t, CombatUnit caster, Tile 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
 }
示例#5
0
    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);
    }
示例#6
0
    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();
    }
示例#7
0
    public static void Charge1(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);

        targetUnit = ActionPatterns.TargetUnit(targetTile);
        if (targetUnit)
        {
            bool critical   = Action.GetCritical();
            bool hitSuccess = Action.HitSuccess(caster, targetUnit, 100);
            int  damage     = Action.Mod2(caster.PA, critical, Element.None, caster, targetUnit, action_id);

            if (hitSuccess)
            {
                ActionPatterns.HitDamage(t, caster, targetUnit, damage);
            }
            else
            {
                ActionPatterns.HitAvoid(t, caster, targetUnit);
            }
        }

        t.gameObject.AddComponent <UnitAnimation_TimelineEvent>().Init(t, 1f, caster.GetDefaultAnimation(), caster.GetComponentInChildren <Animator>());
        t.gameObject.AddComponent <DestroyTimeline_TimelineEvent>().Init(t, .25f);
        t.PlayFromStart();
    }
示例#8
0
    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();
    }
示例#9
0
    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();
    }