public override void EnterState(AIController controller)
 {
     // no pathing
     controller.InterruptPath();
     controller.EnablePathfinding(false);
     enteredShootTime = Time.time;
 }
    public override void EnterState(AIController controller)
    {
        // Charge directly at player, no pathing
        controller.InterruptPath();
        controller.EnablePathfinding(false);

        ((ChargeBossController)controller).BeginChargeAttack();
    }
    public override void EnterState(AIController controller)
    {
        // no pathing
        controller.InterruptPath();
        controller.EnablePathfinding(false);
        startedTelegraph = Time.time;

        ChargeBossController bossController = (ChargeBossController)controller;
        bossController.BeginTelegraphAttack();
    }
Esempio n. 4
0
    public override BehaviourSM.StateResponse Update(AIController controller)
    {
        Vector3 lookDirection = controller.target != null? controller.target.transform.position - controller.transform.position : controller.transform.forward;
        lookDirection.Normalize();

        // lerp towards the current look direction
        Vector3 currentFacing = controller.headTransform.up;
        controller.headTransform.up = Vector3.RotateTowards(currentFacing, lookDirection, controller.baseAimRotSpeed * Time.deltaTime, 0.0f);

        if(isBursting) {
            controller.SetCanMove(false);
        }
        else {
            controller.SetCanMove(true);
        }

        // Update the current weapon
        if(controller.MechComponent != null && controller.MechComponent.leftWeapon != null) {
            controller.MechComponent.leftWeapon.UpdateAIAttackState(controller);
        }

        bool hasLos = controller.HasLOSTarget();
        if(hasLos) {
            lastSawTargetTime = Time.time;
            lastKnownTargetPos = controller.target.transform.position;

            // move to new shooting position at random intervals
            if(Time.time - lastMoveTime > currentMoveInterval) {
                lastMoveTime = Time.time;
                currentMoveInterval = Random.Range(minMoveInterval, maxMoveInterval);

                float engagementRange = controller.GetAttackRange();

                // the ideal location is some distance away from target, slightly random direction offset though
                Vector3 offsetDirection = (lookDirection + (Vector3)Random.insideUnitCircle).normalized;
                Vector3 shootingPosition = controller.target.transform.position - offsetDirection * engagementRange;

                controller.SetMovetoTarget(shootingPosition);
            }
        }
        else {
            // If its run out of LOS, move towards the last known position of the target
            if(controller.target != null) {
                controller.SetMovetoTarget(controller.target.transform.position);
            }
        }

        // Handle firing at target
        AttackTarget(controller);

        // TRANSITIONS:
        // give up looking for target, go to previous state
        if(!hasLos && Time.time - lastSawTargetTime > attentionSpan ||controller.target == null) {
            controller.InterruptPath();
            return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.PopPrevious);
        }

        return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange);
    }