コード例 #1
0
        protected override BTResult ExecuteInternal()
        {
            if (!running)
            {
                finished = false;
                running  = true;
                btResult = BTResult.Running;
                GetNode <Eventing>(Eventing.EventingNodePath).Connect(nameof(Eventing.TreeInfested), this, nameof(TreeInfested));
                GetNode <Eventing>(Eventing.EventingNodePath).Connect(nameof(Eventing.TargetCannotBeReached), this, nameof(TargetCannotBeReached));
                var treeToInfestWorldPosition = GetTreeToInfestWorldPosition();
                if (treeToInfestWorldPosition == new Vector2(-1, -1))
                {
                    stateMachine.TransitionTo(stateMachine.idle);
                    TargetCannotBeReached();
                }
                else
                {
                    stateMachine.TransitionTo(stateMachine.infestTree, new MoveToPositionMessage(treeToInfestWorldPosition));
                }
            }

            if (finished && running)
            {
                running = false;
                return(btResult);
            }

            return(btResult);
        }
コード例 #2
0
        protected override BTResult ExecuteInternal()
        {
            if (!(stateMachine.GetCurrentState() is DemonIdleState))
            {
                Logger.Debug("Demon is going to idle");
                stateMachine.TransitionTo(stateMachine.idle);
            }

            return(BTResult.Success);
        }
コード例 #3
0
        protected override BTResult ExecuteInternal()
        {
            if (!running)
            {
                finished = false;
                running  = true;
                btResult = BTResult.Running;
                GetNode <Eventing>(Eventing.EventingNodePath).Connect(nameof(Eventing.DemonTargetReached), this, nameof(TargetReached));
                GetNode <Eventing>(Eventing.EventingNodePath).Connect(nameof(Eventing.TargetCannotBeReached), this, nameof(TargetCannotBeReached));
                stateMachine.TransitionTo(stateMachine.moveToPosition, new MoveToPositionMessage(GetWanderWorldPosition()));
            }

            if (finished && running)
            {
                running = false;
                return(btResult);
            }

            return(btResult);
        }