Пример #1
0
    private void ApplyAICommand(DoodAIOutput btCommand)
    {
        if (btCommand.moveTo.HasValue)
        {
            navMeshAgent.isStopped = false;
            navMeshAgent.SetDestination(btCommand.moveTo.Value);
        }

        if (btCommand.stopMoving)
        {
            navMeshAgent.isStopped = true;
        }

        if (!string.IsNullOrEmpty(btCommand.playAnimation))
        {
            anim.Play(btCommand.playAnimation);
        }

        if (btCommand.markAggroAs.HasValue)
        {
            behaviourTree.data.hasAggro = btCommand.markAggroAs.Value;
            anim.HasAggro = btCommand.markAggroAs.Value;
        }

        if (btCommand.turnTowards.HasValue)
        {
            transform.LookAt2D(btCommand.turnTowards.Value, Time.deltaTime * 180f);
            anim.IsTurning = true;
        }
        else
        {
            anim.IsTurning = false;
        }
    }
Пример #2
0
 protected override BTState OnTick()
 {
     command = new DoodAIOutput {
         markAggroAs = false
     };
     return(BTState.Success);
 }
Пример #3
0
        protected override void OnStartedTicking()
        {
            command = new DoodAIOutput {
                stopMoving    = true,
                playAnimation = "enemy-punch",
            };

            endTime = Time.time + data.durationOfAnim["enemy-punch"];
        }
Пример #4
0
        protected override void OnStartedTicking()
        {
            command = new DoodAIOutput {
                markAggroAs   = true,
                playAnimation = "zomb-aggro",
                stopMoving    = true
            };

            endTime = Time.time + data.durationOfAnim["zomb-aggro"];
        }
Пример #5
0
        protected override BTState OnTick()
        {
            if (!hasMoved)
            {
                hasMoved = true;
                command  = new DoodAIOutput {
                    moveTo = moveTo
                };
                return(BTState.Continue);
            }

            return(MoveUntilDone(data));
        }
Пример #6
0
        protected override BTState OnTick()
        {
            if (Vector3.Distance(data.playerPos, data.doodPos) > data.doodVisionRange)
            {
                return(BTState.Failure);
            }

            var angleToPlayer = FindAngleToPlayer();

            if (angleToPlayer < 15f)
            {
                return(BTState.Success);
            }

            command = new DoodAIOutput {
                turnTowards = data.playerPos
            };

            return(BTState.Continue);
        }