Example #1
0
    public override void Execute(ActorController entityType)
    {
        if (entityType.IsStun || entityType.IsCaught)
        {
            return;
        }
        if (entityType.TargetEnemy == null)
        {
            entityType.GetFSM().ChangeState(Actor_StateBeforeFight.Instance());
            return;
        }

        this.attackSpeedCounter += Time.deltaTime;
        if (this.attackSpeedCounter >= entityType.AttackInterval)
        {
            entityType.SelfAnimator.Play();
            entityType.SelfAnimator.AnimationCompleted = delegate
            {
                entityType.SelfAnimator.SetFrame(0);
                entityType.SendDamage(
                    entityType.TargetEnemy,
                    entityType.CalculateCommonAttackDamage(entityType.TargetEnemy));
            };
            this.SendBulletToEnemy(entityType);
            this.PlayVampireAnimation(entityType);
            this.attackSpeedCounter = 0f;
        }
    }
Example #2
0
    public override void Execute(ActorController entityType)
    {
        if (entityType.IsStun || entityType.IsCaught)
        {
            return;
        }
        Vector3 moveDistance = entityType.moveSpeed * Time.deltaTime
                               * (entityType.ActorPath.CurrentNode() - entityType.myTransform.position).normalized;

        entityType.myTransform.Translate(moveDistance, Space.World);
        if (entityType.ActorPath.CurrentIndex == entityType.ActorPath.NodesCount() - 1)
        {
            if (Vector3.Distance(entityType.ActorPath.CurrentNode(), entityType.myTransform.position)
                <= entityType.MyActor.ActorAttack.AttackRange)
            {
                if (entityType.TargetBuilding != null)
                {
                    entityType.TargetEnemy = entityType.TargetBuilding.GetComponent <BuildingController>();
                    entityType.GetFSM().ChangeState(Actor_StateFight.Instance());
                }
                return;
            }
        }
        if ((entityType.ActorPath.CurrentNode() - entityType.myTransform.position).sqrMagnitude <= 0.5)
        {
            if (entityType.ActorPath.HasNext())
            {
                entityType.ActorPath.NextNode();
                this.ResetRotation(entityType);
            }
        }

        this.seekEnemyCounter += Time.deltaTime;
        if (this.seekEnemyCounter >= this.seekEnemyInterval)
        {
            if (entityType.SeekAndGetEnemies(false).Count != 0 || entityType.SeekAndGetEnemyBuildings().Count != 0)
            {
                entityType.GetFSM().ChangeState(Actor_StateBeforeFight.Instance());
            }
            else
            {
                List <GameObject> enemies =
                    entityType.SeekAndGetEnemiesInDistance(entityType.MyActor.ActorAttack.AttackRange, false);
                if (enemies.Count != 0)
                {
                    if (enemies[0] != null)
                    {
                        entityType.TargetEnemy = enemies[0].GetComponent <ActorController>();
                        entityType.GetFSM().ChangeState(Actor_StateFight.Instance());
                    }
                }
            }
            this.seekEnemyCounter = 0.0f;
        }
    }
Example #3
0
    public override void Enter(ActorController entityType)
    {
        this.attackSpeedCounter = 0.0f;
        if (entityType.TargetEnemy == null)
        {
            entityType.GetFSM().ChangeState(Actor_StateBeforeFight.Instance());
            return;
        }
        StringBuilder animName = new StringBuilder(entityType.MyActor.RaceType + "_");

        animName.Append(entityType.MyActor.ActorType);
        animName.Append("_Attack_");
        animName.Append(entityType.MyActor.FactionType);
        entityType.SelfAnimator.Play(animName.ToString());
        entityType.SelfAnimator.AnimationCompleted = delegate
        {
            entityType.SelfAnimator.SetFrame(0);
            entityType.SendDamage(
                entityType.TargetEnemy,
                entityType.CalculateCommonAttackDamage(entityType.TargetEnemy));
        };
    }