Ejemplo n.º 1
0
    public void SkillAttack()
    {
        SequenceAction demoFight = new SequenceAction();
        Model          actor, target;


        // -----


        AnimeAction projectileAttack;
        AnimeAction attack;

        // Right-0 attack Left-0
        actor  = rightTeam[0];
        target = leftTeam[0];

        projectileAttack = CreateProjectileAction(actor, target, projectilePrefab[0], effectPrefab[0]);
        attack           = CreateAttackAction(actor, target, 0,
                                              false, projectileAttack);
        demoFight.AddAction(attack);


        // Right-1 attack Left-1
        actor  = rightTeam[1];
        target = leftTeam[1];

        projectileAttack = CreateProjectileAction(actor, target, projectilePrefab[1], effectPrefab[1]);
        attack           = CreateAttackAction(actor, target, 1,
                                              false, projectileAttack);
        demoFight.AddAction(attack);

        // -----
        actionManager.RunAction(demoFight);
    }
Ejemplo n.º 2
0
    public AnimeAction CreateHitDamageAction(BattleModel targetModel, AnimationClip hitEffect = null)
    {
        SequenceAction sequence = new SequenceAction();

        sequence.name = "HitSequence";

        if (hitEffect != null)
        {
            SimpleAnimationAction effectAction = new SimpleAnimationAction();
            effectAction.clip          = slashEffect;
            effectAction.spawnPosition = targetModel.transform.position + new Vector3(0, 1, -2);
            sequence.AddAction(effectAction);
        }

        HitAction hitAction = new HitAction();

        hitAction.name  = "enemyHit";
        hitAction.actor = targetModel;
        sequence.AddAction(hitAction);


        HitValueAction damageAction = new HitValueAction();

        damageAction.valueTextPrefab = hitValuePrefab;
        damageAction.hitValue        = 1000;
        damageAction.position        = targetModel.transform.position + new Vector3(0, 2, -2);
        sequence.AddAction(damageAction);

        return(sequence);
    }
Ejemplo n.º 3
0
    public void OneOnOne()
    {
        Debug.Log("###### TEST 1 ######");
        SequenceAction demoFight = new SequenceAction();

        Model actor, target;


        // Right-0 attack Left-0
        actor = rightTeam[0];  target = leftTeam[0];
        AnimeAction p1Attack = CreateAttackAction(actor, target, 0,
                                                  true, CreateHitDamageAction(target));


        // Left-0 attack Right-1
        actor = leftTeam[0];  target = rightTeam[0];
        AnimeAction p2Attack = CreateAttackAction(actor, target, 0,
                                                  true, CreateHitDamageAction(target, effectPrefab[1]));



        demoFight.AddAction(p2Attack);
        demoFight.AddAction(p1Attack);

        actionManager.RunAction(demoFight);
    }
Ejemplo n.º 4
0
    public void EnemyHit()
    {
        SequenceAction sequence = new SequenceAction();

        sequence.name = "HitSequence";

        AnimatorAction action = new AnimatorAction();

        action.name         = "enemyHit";
        action.animator     = enemyAnimator;
        action.triggerState = "Hit";
        sequence.AddAction(action);


        HitValueAction hitAction = new HitValueAction();

        hitAction.valueTextPrefab = hitValuePrefab;
        hitAction.hitValue        = 1000;
        hitAction.position        = enemyAnimator.transform.position + new Vector3(0, 1, -2);
        sequence.AddAction(hitAction);
        //hitAction.position = new Vector3(0, 0, -2);

        actionManager.RunAction(sequence);
        //action.animator = bat
    }
Ejemplo n.º 5
0
    public void CharCast2()
    {
        SequenceAction sequence = new SequenceAction();

        sequence.name = "CastSequence";

        AnimatorAction action;

        action              = new AnimatorAction();
        action.doneWhenHit  = true;
        action.name         = "character";
        action.animator     = charAnimator;
        action.triggerState = "Cast";
        sequence.AddAction(action);


        AnimatorAction fireAction = new AnimatorAction();

        fireAction.name         = "vfx2";
        fireAction.animator     = animator2;
        fireAction.triggerState = "Fire";
        sequence.AddAction(fireAction);

        actionManager.RunAction(sequence);
    }
Ejemplo n.º 6
0
    public void Range2()
    {
        // Projectile Action
        SequenceAction sequence         = new SequenceAction();
        AnimeAction    projectileAction = CreateProjectileAction(hero.GetLaunchPosition(), target.transform.position);

        sequence.AddAction(projectileAction);
        sequence.AddAction(CreateTargetHitDamageAction());

        //
        AttackAction attackAction = CreateActorAttackAction(1, false, sequence);

        actionManager.RunAction(attackAction);
    }
Ejemplo n.º 7
0
    public void FightDemo1()
    {
        SequenceAction demoFight = new SequenceAction();


        AnimeAction p1Attack = CreateAttackAction(enemy, hero, 0,
                                                  true, CreateHitDamageAction(hero));

        demoFight.AddAction(p1Attack);

        AnimeAction p2Attack = CreateAttackAction(hero, enemy, 0,
                                                  true, CreateHitDamageAction(enemy, slashEffect));

        demoFight.AddAction(p2Attack);

        actionManager.RunAction(demoFight);
    }
Ejemplo n.º 8
0
    public AnimeAction CreateProjectileAction(Model actor,
                                              Model target,
                                              GameObject projectile,
                                              GameObject hitEffect)
    {
        // Sequence: Projectile Movement, Hit Effect, ModelHit HitValue

        SequenceAction sequence = new SequenceAction();

        Vector3 launchPos       = actor.GetLaunchPosition();
        Vector3 targetCenterPos = (Vector3)target.GetCenterPosition() + new Vector3(0, 0, -5);
        Vector3 targetPos       = (Vector3)target.GetOriginPosition() + new Vector3(0, 0, -5);
        float   duration        = 0.5f;

        // Projectile Move
        EffectAction projectileAction = EffectAction.CreateProjectileEffect(
            projectile, launchPos, targetCenterPos, duration);

        sequence.AddAction(projectileAction);

        // Hit Effect
        ParallelAction damagePack = new ParallelAction();

        sequence.AddAction(damagePack);

        EffectAction effectAction = EffectAction.CreatePointEffect(hitEffect, targetPos);

        damagePack.AddAction(effectAction);

        ModelHitAction hitAction = new ModelHitAction();

        hitAction.name  = "enemyHit";
        hitAction.actor = target;
        damagePack.AddAction(hitAction);


        int            damage       = Random.Range(500, 10000);
        GameTextAction damageAction = GameTextAction.Create(
            damageTextPrefab, damage.ToString(), target.transform.position + new Vector3(0, 2, -2));

        damagePack.AddAction(damageAction);

        return(sequence);
    }
Ejemplo n.º 9
0
    public AnimeAction CreateProjectileAction(Vector3 startPos, Vector3 targetPos)
    {
        ObjectMoveAction projectAction = new ObjectMoveAction();

        projectAction.startPosition = startPos + new Vector3(0, 0, zOrderVfx);;
        projectAction.endPosition   = targetPos + new Vector3(0, 1, zOrderVfx);
        projectAction.objectPrefab  = projectilePrefab;
        projectAction.SetDuration(0.5f);

        SimpleAnimationAction explodeAction = new SimpleAnimationAction();

        explodeAction.clip          = explodeEffect;
        explodeAction.spawnPosition = targetPos + new Vector3(0, 0, zOrderVfx);
        explodeAction.repeat        = 1;

        SequenceAction fullFireAction = new SequenceAction();

        fullFireAction.AddAction(projectAction);
        fullFireAction.AddAction(explodeAction);

        return(fullFireAction);
    }
Ejemplo n.º 10
0
    public void MeleeEffect()
    {
        SequenceAction sequence = new SequenceAction();

        bool isMoving = true;

        foreach (GameObject effect in effectPrefab)
        {
            AnimeAction action = CreateEffectAttack(rightTeam[1], leftTeam[0], isMoving, effect);
            sequence.AddAction(action);
        }

        AnimeActionManager.Instance.RunAction(sequence);
    }
Ejemplo n.º 11
0
    public AnimeAction GetTargetHitDamageAction()
    {
        SequenceAction sequence = new SequenceAction();

        sequence.name = "HitSequence";

        AnimatorAction hitAction = new AnimatorAction();

        hitAction.name         = "enemyHit";
        hitAction.animator     = target;
        hitAction.triggerState = "Hit";
        sequence.AddAction(hitAction);


        HitValueAction damageAction = new HitValueAction();

        damageAction.valueTextPrefab = hitValuePrefab;
        damageAction.hitValue        = 1000;
        damageAction.position        = target.transform.position + new Vector3(0, 1, -2);
        sequence.AddAction(damageAction);

        return(sequence);
    }
Ejemplo n.º 12
0
    public void CastProjectile()
    {
        // Using ObjectMove
        ObjectMoveAction projectAction = new ObjectMoveAction();

        projectAction.startPosition = player.GetLaunchPosition() + new Vector3(0, 0, zOrderVfx);;
        projectAction.endPosition   = enemyAnimator.transform.position + new Vector3(0, 1, zOrderVfx);
        projectAction.objectPrefab  = projectilePrefab;
        projectAction.SetDuration(0.5f);

        SimpleAnimationAction explodeAction = new SimpleAnimationAction();

        explodeAction.clip          = animeClip;
        explodeAction.spawnPosition = enemyAnimator.transform.position + new Vector3(0, 0, zOrderVfx);
        explodeAction.repeat        = 1;

        SequenceAction fullFireAction = new SequenceAction();

        fullFireAction.AddAction(projectAction);
        fullFireAction.AddAction(explodeAction);

        // Using MoveAction
        // MoveAction moveAction = new MoveAction();
        // moveAction.startPosition = player.GetLaunchPosition();
        // moveAction.endPosition = enemyAnimator.transform.position + new Vector3(0, 1, 0);
        // moveAction.targetObject = testObject;
        // moveAction.SetDuration(0.5f);

        AnimatorAction animeAction = new AnimatorAction();

        animeAction.name         = "character";
        animeAction.animator     = charAnimator;
        animeAction.triggerState = "Cast";
        animeAction.onHitAction  = fullFireAction;

        actionManager.RunAction(animeAction);
    }
Ejemplo n.º 13
0
        /// <summary>
        /// 创建自动战斗的行为树。
        /// </summary>
        /// <returns>自动战斗的行为树。</returns>
        private Action CreateBehaviorTree()
        {
            ParallelAction ret = new AutoAI.ParallelAction();

            //保持血量
            SequenceAction keeplife = new SequenceAction();

            keeplife.AddAction(new AutoAICheckLife());
            keeplife.AddAction(new AutoAICheckPotion());
            keeplife.AddAction(new AutoAIUsePotion());
            ret.AddAction(new RepeatAction(keeplife, 0, 5));

            //战斗
            SequenceAction   fight = new SequenceAction();
            AutoAIFindTarget find  = new AutoAIFindTarget();

            fight.AddAction(find);
            fight.AddAction(new MoveAction(Vector3.zero, 0, find.GetTargetPosition));
            fight.AddAction(new AutoAIAttackTarget());
            ret.AddAction(new RepeatAction(fight));

            //复活
            return(ret);
        }
Ejemplo n.º 14
0
    public void AttackFromTeam(SequenceAction sequence, BattleModel[] attackTeam, BattleModel[] targetTeam)
    {
        for (int i = 0; i < attackTeam.Length; i++)
        {
            BattleModel actor  = attackTeam[i];
            BattleModel target = targetTeam[i];

            short style = (short)Random.Range(0, 2);

            AnimeAction attackAttack = CreateAttackAction(actor, target, style,
                                                          true, CreateHitDamageAction(target, slashEffect[0]));
            sequence.AddAction(attackAttack);
            //for(BattleModel actor in attackTeam) {
        }
    }
Ejemplo n.º 15
0
    public AnimeAction CreateCastAction(string name, string vfx, Animator target, int damage)
    {
        SequenceAction sequence = new SequenceAction();

        sequence.name = name;

        Vector3 targetPosition = target.transform.position;

        AnimatorAction animeAction;



        VFXAction vfxAction = new VFXAction();

        vfxAction.name      = "vfxAction";
        vfxAction.vfxName   = vfx;
        vfxAction.position  = targetPosition + new Vector3(0, 0, -2);
        vfxAction.vfxPrefab = vfxPrefab;
        sequence.AddAction(vfxAction);

        animeAction              = new AnimatorAction();
        animeAction.name         = "enemyHit";
        animeAction.animator     = target;
        animeAction.triggerState = "Hit";
        sequence.AddAction(animeAction);


        HitValueAction hitAction = new HitValueAction();

        hitAction.valueTextPrefab = hitValuePrefab;
        hitAction.hitValue        = damage;
        hitAction.position        = targetPosition + new Vector3(0, 1, -2);
        sequence.AddAction(hitAction);

        return(sequence);
    }
Ejemplo n.º 16
0
    public void AttackFromTeam(SequenceAction sequence, Model[] attackTeam, Model[] targetTeam)
    {
        for (int i = 0; i < attackTeam.Length; i++)
        {
            Model actor  = attackTeam[i];
            Model target = targetTeam[i];

            short style = (short)Random.Range(0, 2);

            effectIndex++;
            int effectIdx = effectIndex % 2;

            AnimeAction attackAttack = CreateAttackAction(actor, target, style,
                                                          true, CreateHitDamageAction(target, effectPrefab[effectIdx]));
            sequence.AddAction(attackAttack);
            //for(Model actor in attackTeam) {
        }
    }