Exemplo n.º 1
0
    public override NodeState RunNode(float p_delta)
    {
        Script_IEntity targetEntity   = _tree.GetBlackBoardElement <Script_IEntity>(_targetEnemyFlag);
        bool           isForwardSwing = _tree.GetBlackBoardElement <bool> (_isForwardSwingFlag);

        if (targetEntity == null || targetEntity.GetGameObject() == null)
        {
            return(NodeState.Failed);
        }

        if (isForwardSwing)
        {
            NodeState success = ForwardSwing(p_delta, _entityToAttack.GetGridLocation(), _entityToAttack, targetEntity);
            if (success == NodeState.Success)
            {
                Script_Projectile projectile = new Script_Projectile(_manager, _entityToAttack, targetEntity, _projectileColor);
                _manager.CreateProjectile(projectile);
                return(NodeState.Success);
            }
        }
        else if (!isForwardSwing)
        {
            BackSwing(p_delta, _entityToAttack.GetGridLocation(), _entityToAttack, targetEntity);
        }
        return(NodeState.Running);
    }